LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Compiler issue c99 (https://www.linuxquestions.org/questions/linux-software-2/compiler-issue-c99-504428/)

sgriffiths 11-24-2006 05:14 AM

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

matthewg42 11-24-2006 08:35 AM

what command are you using to compile the code, and what is the code segment (please post in [code] tags)?

sgriffiths 11-24-2006 08:59 AM

Quote:

Originally Posted by matthewg42
what command are you using to compile the code, and what is the code segment (please post in [code] tags)?

Code:

for(int i=0;i<len_string;i++)
{
        ch = string[i];
        if(ch != GLITCH)
        { 
            Split_Val[counter] = ch;
            counter++;
        }                                       
}   
Split_Val[counter]=NULL;

i am using gcc

matthewg42 11-24-2006 09:09 AM

what command to compile (including options)

sgriffiths 11-24-2006 09:14 AM

'LINK_OPTIONS=-xarch=v9' \
'CFLAGS=-xO3 -xarch=v9 -DVERSION=$(VERSION) -DID=$(ID) -D_FILE_OFFSET_BITS=64 -Linux'
'LINK=-lgen -ldl'

matthewg42 11-24-2006 10:00 AM

add "--std=c99" to your compiling command.

sgriffiths 11-27-2006 03:45 AM

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 :)

sgriffiths 11-27-2006 04:37 AM

Sorry

The compiling options i am using are as follows:

cc -std=c99

Wim Sturkenboom 11-28-2006 12:35 AM

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).

sgriffiths 11-29-2006 03:23 AM

Quote:

Originally Posted by Wim Sturkenboom
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).

Here are the error messages i am seeing

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.