I noticed two things:
- applying anything in
*build_flags
breaksinline
keyword unless optimisation setting happens to be last in*build_flags
- applying any
debug_build_flags
breaks debugging
I even made “clean” project in attempt to isolate issue.
My platformio.ini:
[platformio]
src_dir = Src
include_dir = Inc
[common]
debug_flagz = -DHELLO_THERE=1
normal_flagz = -DGENERAL_KENOBI=1
[env:disco_f030r8]
platform = ststm32
board = disco_f030r8
framework = stm32cube
; Broken inline in debug, build works fine
debug_build_flags = ${common.debug_flagz}
; Debug with dbgasm, no preview in c
; debug_build_flags = ${common.debug_flagz} -Og
; Works fine
; build_unflags = -Os
; build_flags = ${common.normal_flagz} -O3
; Now build doesnt recognize inline keyword
build_flags = ${common.normal_flagz}
debug_tool = jlink
upload_protocol = jlink
Removing jlink lines doesn’t make any difference.
I tried multiple combinations of commented lines, and different flags. Even working versions didn’t seem to work after applying broken one until vscode restart. For sake of completeness part of my main.c:
volatile uint8_t counter = 0;
inline void toggle_led3(void){
HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
}
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
while (1)
{
counter++;
#ifdef HELLO_THERE
HAL_GPIO_WritePin(LD4_GPIO_Port,LD4_Pin, 1);
#endif
#ifdef GENERAL_KENOBI
HAL_GPIO_TogglePin(LD4_GPIO_Port,LD4_Pin);
#endif
toggle_led3();
HAL_Delay(100);
}
}
And compiler error produced in broken state:
.pio/build/disco_f030r8/src/main.o: In function `main':
main.c:(.text.main+0x2c): undefined reference to `toggle_led3'
collect2: error: ld returned 1 exit status
*** [.pio/build/disco_f030r8/firmware.elf] Error 1
After removing inline
from function definition code compiles and works fine.
Generating flags with pre python script works fine.
Am i doing something wrong? I’ve been using build_flags in my projects since more than a year ago, and I don’t recall inline breaking, could be that I just don’t like inline functions, I guess. I only noticed that I am onto something when I added debug_build_flags.
If anybody wants to try it, i did put my test project on github:
https://github.com/tosmaz/buildflagstest