cancel
Showing results for 
Search instead for 
Did you mean: 

Change Compiler Mode Question.

mbmail4
Associate II
Posted on March 22, 2016 at 12:11

I'm using System Works IDE, and when I compile my stm32 program I get an error.

error: 'for' loop initial declarations are only allowed in C99 or C11 mode.

I know what the complaint is about but how do I set up C11compiler mode, I cant find a switch in the settings dialog box.

thanks

3 REPLIES 3
Posted on March 22, 2016 at 14:19

Try .cpp file, or ''Compile as C++'' like options, I don't use this IDE

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TarekB-ST
Associate III
Posted on March 22, 2016 at 14:53

I guess that you are using c90 as dialect.

this compilation error appears when you are not using C99 and you have written this kind of code :

for(int i=0; ....

to fix this problem, you have two options:

  1. declare 'i' outside of the loop
  2. change dialect to C99 : project Properties > C/C++ Build > Settings > Tool Setting [TAB] > MCU GCC Compiler > Dialect > Language standard :: select ISO C99

For me I would prefer to change my code to be dialect compliant.

And if I had to change dialect I will use gnu99 (not c99) since SystemWorkbech uses a GNU compiler (other dialect flags : -std=gnu99)

Regards,

TarekB

mbmail4
Associate II
Posted on March 22, 2016 at 22:27

thank you tarekb, I changed it to -std=gnu99, it worked.

mb