Shop OBEX P1 Docs P2 Docs Learn Events
error: 'for' loop initial .... — Parallax Forums

error: 'for' loop initial ....

doggiedocdoggiedoc Posts: 2,243
edited 2012-08-18 17:53 in Propeller 1
...declarations are only allowed in C99 mode.
Note: use option -std=c99 or -std=gnu99 to compile your code.

How do I select this option? I've tried adding -std=c99 to "Other Compile Options" but get waaaay more errors after that.

SimpleIDE.png


Thanks!
Paul

PS: obviously I could just declare the variable in a separate statement but the thing is I kinda like declaring it inline with the 'for' statement. :D

PPS: Using Mac OS 10.8 and SIDE version 0.7.2
786 x 582 - 152K

Comments

  • doggiedocdoggiedoc Posts: 2,243
    edited 2012-08-18 16:51
    So... most of the new errors are warnings about local variables but the inline declaration in the for loop mentioned about still doesn't seem to work. I realize I am doing something wrong. I just don't know what. :D
    Project Directory: /SimpleIDE/My SIDE Projects/HB25/
    
    propeller-elf-gcc -o a.out -Os -mlmm -I . -fno-exceptions -std=c99 HB25.c
    HB25.c: In function 'SetMotor1':
    HB25.c:40:6: warning: type of 'Motor1WidthNew_' defaults to 'int' [enabled by default]
    HB25.c: In function 'SetMotor2':
    HB25.c:45:6: warning: type of 'Motor2WidthNew_' defaults to 'int' [enabled by default]
    HB25.c: In function 'SetMotorS':
    HB25.c:49:6: warning: type of 'Motor1WidthNew_' defaults to 'int' [enabled by default]
    HB25.c:49:6: warning: type of 'Motor2WidthNew_' defaults to 'int' [enabled by default]
    HB25.c: In function 'SetRamp':
    HB25.c:54:6: warning: type of 'Motor1Rate_' defaults to 'int' [enabled by default]
    HB25.c:54:6: warning: type of 'Motor2Rate_' defaults to 'int' [enabled by default]
    HB25.c: In function 'Pause':
    HB25.c:59:6: warning: type of 'Duration' defaults to 'int' [enabled by default]
    HB25.c:61:5: warning: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
    HB25.c: In function 'PULSOUT':
    HB25.c:65:6: warning: type of 'Pin' defaults to 'int' [enabled by default]
    HB25.c:65:6: warning: type of 'Duration' defaults to 'int' [enabled by default]
    HB25.c: In function 'Pulse':
    HB25.c:76:6: warning: type of 'Pin' defaults to 'int' [enabled by default]
    HB25.c:76:6: warning: type of 'Motor1Width_' defaults to 'int' [enabled by default]
    HB25.c:76:6: warning: type of 'Motor2Width_' defaults to 'int' [enabled by default]
    HB25.c: In function 'main':
    HB25.c:93:10: error: 'rampVal' undeclared (first use in this function)
    HB25.c:93:10: note: each undeclared identifier is reported only once for each function it appears in
    Done. Build Failed!
    
    Click error or warning messages above to debug.
    
  • amossamamossam Posts: 35
    edited 2012-08-18 17:00
    heya

    well, inline declaration works, but that variable is declared only if first loop and only for that loop!
    you need to declare it again in second loop! line 93
    and for warnings, without more code it's hard to tell...

    my 1.2 cents...
  • doggiedocdoggiedoc Posts: 2,243
    edited 2012-08-18 17:53
    Thank you! You just taught me how to read the error line output! Now I understand!!
Sign In or Register to comment.