LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-24-2006, 05:14 AM   #1
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Rep: Reputation: 0
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
 
Old 11-24-2006, 08:35 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
what command are you using to compile the code, and what is the code segment (please post in [code] tags)?
 
Old 11-24-2006, 08:59 AM   #3
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
Old 11-24-2006, 09:09 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
what command to compile (including options)
 
Old 11-24-2006, 09:14 AM   #5
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Original Poster
Rep: Reputation: 0
'LINK_OPTIONS=-xarch=v9' \
'CFLAGS=-xO3 -xarch=v9 -DVERSION=$(VERSION) -DID=$(ID) -D_FILE_OFFSET_BITS=64 -Linux'
'LINK=-lgen -ldl'
 
Old 11-24-2006, 10:00 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
add "--std=c99" to your compiling command.
 
Old 11-27-2006, 03:45 AM   #7
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
Old 11-27-2006, 04:37 AM   #8
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Sorry

The compiling options i am using are as follows:

cc -std=c99
 
Old 11-28-2006, 12:35 AM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
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).
 
Old 11-29-2006, 03:23 AM   #10
sgriffiths
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
C99 libs in ISO C++ ta0kira Programming 0 05-20-2005 02:12 AM
openxchange java compiler issue TheNorwegian Fedora 1 11-08-2004 10:11 AM
Compiler conundrum: Which came first, a compiler, or it's source code? fr0zen Programming 21 01-29-2004 04:31 AM
compile a compiler without a compiler? lackluster Linux - General 18 01-02-2003 07:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration