Compiler issue c99
hello all
I have written a peice of C code which i run and compile on SunSolaris. I have tried to compile this source code on linux with the following errors error: for loop initial declaration used outside C99 mode error: (Each undeclared identifier is reported only once split_field.c:955: error: for each function it appears in.) Can anyone assist? best regards |
what command are you using to compile the code, and what is the code segment (please post in [code] tags)?
|
Quote:
Code:
for(int i=0;i<len_string;i++) |
what command to compile (including options)
|
'LINK_OPTIONS=-xarch=v9' \
'CFLAGS=-xO3 -xarch=v9 -DVERSION=$(VERSION) -DID=$(ID) -D_FILE_OFFSET_BITS=64 -Linux' 'LINK=-lgen -ldl' |
add "--std=c99" to your compiling command.
|
I have the below now as my compiler options
gcc -std=c99 -DVERSION=$(VERSION) -DID=$(ID) -DLinux It still generates the sames errors though! Any more help :) |
Sorry
The compiling options i am using are as follows: cc -std=c99 |
According to the error message, for(int i=0;i<len_string;i++) is not allowed.
Declare your counter (i) at the beginning of the function and remove the bold part from the for-loop. As far as I know, the construction that you use is C++ and not C; I might however be mistaken here. PS there is dedicated programming section on LQ. Your question probably fits better in there; you can report your post and request it to be moved (if you agree with the suggestion). |
Quote:
split_field.c: In function âbuild_field_infoâ: split_field.c:370: error: âcaddr_tâ undeclared (first use in this function) split_field.c:370: error: (Each undeclared identifier is reported only once split_field.c:370: error: for each function it appears in.) split_field.c:370: error: syntax error before numeric constant split_field.c: At top level: split_field.c:686: error: syntax error before numeric constant split_field.c:686: warning: type defaults to âintâ in declaration of âPrintâ split_field.c:686: error: conflicting types for âPrintâ general.h:59: error: previous declaration of âPrintâ was here split_field.c:686: warning: data definition has no type or storage class split_field.c: In function âbuild_param_infoâ: split_field.c:757: error: assignment of read-only location split_field.c:758: error: assignment of read-only location split_field.c:777: warning: assignment makes integer from pointer without a cast split_field.c:783: warning: passing argument 1 of âstrcpyâ from incompatible pointer type split_field.c:757: confused by earlier errors, bailing out |
All times are GMT -5. The time now is 06:59 PM. |