gcc settings

Everything about embedded cross-compilers

gcc settings

Postby epooch on Tue Oct 25, 2005 4:50 pm

I am having some problems getting my code to compile. I tried adding "-std=c99", to the CFLAGS in cross-makefile, but the cross-compiler is still giving me errors like: "`variable' undeclared (first use in this function)"
with code that does not have the variable declarations at the beginning of the method. Is there something I am missing?

thanks
epooch
 
Posts: 11
Joined: Tue Oct 25, 2005 10:38 am

Postby hns on Tue Oct 25, 2005 11:38 pm

Hm,
difficult to say. Most probably it might look for a header file that it does not find.

Can you post a code fragment or a compile log?

-- hns
hns
Site Admin
 
Posts: 328
Joined: Tue Apr 27, 2004 8:06 pm

Postby epooch on Wed Oct 26, 2005 2:25 am

I don't think it is a header file, but rather a gcc build setting that is being very strict with the code. Very Simplified Code:
Code: Select all
- (id)init;
{
   [super init];
   NSArray *tmpArray;
   tmpArray = [NSArray arrayWithObjects:@"test", nil];
   return self;
}


CSTestComms.m: In function `-[CSTestComms init]':
CSTestComms.m:142: parse error before `*'
CSTestComms.m:143: `tmpArray' undeclared (first use in this function)
CSTestComms.m:143: (Each undeclared identifier is reported only once
CSTestComms.m:143: for each function it appears in.)

Code: Select all
- (id)init;
{
   NSArray *tmpArray;
   tmpArray = [NSArray arrayWithObjects:@"test", nil];
   [super init];
   return self;
}


no errors.

Thanks for the help!
epooch
 
Posts: 11
Joined: Tue Oct 25, 2005 10:38 am

Postby hns on Wed Oct 26, 2005 7:06 am

Ah,
that is a situation I also know. The gcc is 2.95.3 is by default strict about the position of variable declarations.

But I found in the gcc 2.95.3 manual at http://gcc.gnu.org/onlinedocs/gcc-2.95. ... .html#SEC6 that you should specify

-fstd=c99 or -fstd=c9x (it is not exactly precise about if the x should be replaced by a 0 or 9).

-- hns
hns
Site Admin
 
Posts: 328
Joined: Tue Apr 27, 2004 8:06 pm

Postby epooch on Wed Oct 26, 2005 9:15 am

are you sure it is -fstd=c99, and not -std=c99, as I indicated in the first post? either way it does not work. I think I will start from a fresh install.
Thanks for your help.
epooch
 
Posts: 11
Joined: Tue Oct 25, 2005 10:38 am

Postby hns on Wed Oct 26, 2005 10:27 am

-fstd is at least what the manual for gcc 2.95.3 says...

(I can not verify at the moment.)

-- hns
hns
Site Admin
 
Posts: 328
Joined: Tue Apr 27, 2004 8:06 pm

Postby epooch on Thu Oct 27, 2005 4:59 am

Ok, so I reinstalled and I have the same problem:
-fstd=c99 gives and invalid argument error while -std=c99 seems to not do anything (or at least not what I need). I had this problem before in a earlier version of x-code, and -std=c99 fixed it. Adding it to the build script does not seem to help though.
I tried the sample app, and after adding a similar variable definition. I also received a compilation error.
Everything seems to work fine with Apple's gcc though.
Anyway, if anyone has a solution or an example of the a gcc command that they know does not return this error, I would appreciate it.

Thanks
--Eric
epooch
 
Posts: 11
Joined: Tue Oct 25, 2005 10:38 am

Postby hns on Thu Oct 27, 2005 7:47 am

Hm,
I have experimented a little. The Manual seems to be wrong about -fstd=. -std works (gcc --help tells about this option)

-std=c99 does not work, but you could try -std=c9x

-- hns
hns
Site Admin
 
Posts: 328
Joined: Tue Apr 27, 2004 8:06 pm

Postby epooch on Sun Oct 30, 2005 2:47 pm

I guess gcc 2.95 doesn't really support mixed declarations and code even in -std=c99 mode, as it is a c89 compiler. It took me a while to find anything that states this though. Thanks for the help!
epooch
 
Posts: 11
Joined: Tue Oct 25, 2005 10:38 am


Return to Developer / Xtoolchain / Zaurus-X-gcc / QuantumCode

Who is online

Users browsing this forum: No registered users and 1 guest