This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC1350STK: for loop variable declaration

Part Number: CC1350STK

Tool/software: Code Composer Studio

This one should be pretty simple. I'm getting a compiler error when trying to declare a variable in a for loop.

I want to do this:

for(int i = 0; i<10; i++) {}

but have to do this instead:

int i = 0;
for(i = 0; i<10; i++) {}

Its just a minor nuisance and it seems to be project dependent (I can do the shorthand declaration in one project but not another). I haven't found the setting to fix that.

Here's the compiler error:

"../file.c", line 1073: error #29: expected an expression
"../file.c", line 1073: error #20: identifier "i" is undefined

  • Add the build option --c99.  Please read more about it in the section titled Changing the ANSI/ISO C/C++ Language Mode of the ARM compiler manual.  Note this does not work in really old versions of the compiler which do not support --c99.

    Thanks and regards,

    -George

  • Thanks, It was in project properties, Build->ArmCompiler->AdvancedOptions->LanguageOptions.

    Ultimately this was my own dumb fault for changing one file to a cpp file, but not the other. In anycase the default examples were set to -c98, so its probably good to change those anyways.

    Thanks again.