Problems compiling - gcc Command line arguments
Albert E. Whale
aewhale@access.hky.com
Thu Dec 30 08:25:00 GMT 1999
Thanks Erik!
I appreciate the offer for support. Here's the declarations in use:
grep scr_alloc fxscrf.c
scr_alloc(pscrhead);
static int scr_alloc( pscrparent)
The problem that I see here, isn't that the function is declared
external, but rather that it is used before the actual declaration.
Thus the need for gcc to declare it as an external declaration, which is
wrong. (Perhaps the original code needs to be re-written to decalre the
function, before the actual use, that's a bridge I shouldn't cross
because I did not write the original software).
I am using:
[root@Elvis lib]# gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/pgcc-2.91.66/specs
gcc version pgcc-2.91.66 19990314 (egcs-1.1.2 release)
[root@Elvis lib]#
Is this current?
Your suggestions included using some other switches, I just wanted to
show you what happens when I do this.
The -w option definitely does eliminate the warning messages. However,
my concern is that there must be some compiler switch which would
eliminate the same problem I'm experiencing with migrating software.
Let me know what you think.
Erik Mouw wrote:
>
> On Thu, 30 Dec 1999 13:58:52 +0000, Albert E. Whale wrote:
> > I am currently involved in a Migration Project. When I am compiling the
> > source code, I am getting the following Warning statements which appear
> > incocluous, but also prohibit the compilation process.
>
> The warnings you describe are valid, IMHO. Without having access to your
> source, I think your code looks more or less like:
>
> /* declaration */
> int src_alloc(void);
>
> ...
>
> /* implementation */
> static int src_alloc(void)
> {
> /* whatever */
> }
>
> This is indeed an error: the function is declared global, but redefined as
> static.
>
> I'm just guessing, of course, can you show some example code? Can youalso
> tell which gcc version you're using (use "gcc -v" to find out)?
>
> > What is important to note here, is that there are no errors in the
> > software whenever it is compiled on a Non-Linux box. What command line
> > options can I provide to the gcc compiler to reduce the number of
> > warnings and get it to behave more like other compilers?
>
> Gcc is actually quite good at pointing out potential bugs and/or language
> violations; other C compilers are much more permissive. You can consider
> this a bug in the non-gcc compilers, or a feature in gcc.
>
> The flags you can try:
> -w Switch off all warnings. Quite dangerous.
> -ansi Only support ANSI C, no GNU C extensions.
> -traditional Attempt to support some aspects of traditional C compilers.
>
> > fxscrf.c:247: warning: `scr_alloc' was declared implicitly `extern' and
> > later `s
> > tatic'
> > fxscrf.c:123: warning: previous declaration of `scr_alloc'
> > fxscrf.c:269: warning: `scr_free' was declared implicitly `extern' and
> > later `st
> > atic'
> > fxscrf.c:221: warning: previous declaration of `scr_free'
> > fxscrf.c:279: warning: `sub_alloc' was declared implicitly `extern' and
> > later `s
> > tatic'
> > fxscrf.c:186: warning: previous declaration of `sub_alloc'
> > fxscrf.c:336: warning: `sub_free' was declared implicitly `extern' and
> > later `st
> > atic'
> > fxscrf.c:188: warning: previous declaration of `sub_free'
> > fxscrf.c:371: warning: `setrownum' was declared implicitly `extern' and
> > later `s
> > tatic'
> > fxscrf.c:262: warning: previous declaration of `setrownum'
> > fxscrf.c:411: warning: `setslist' was declared implicitly `extern' and
> > later `st
> > atic'
>
> Please show some example code which triggers this warning.
>
> Erik
>
> --
> J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
> of Electrical Engineering, Faculty of Information Technology and Systems,
> Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
> Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
> WWW: http://www-ict.its.tudelft.nl/~erik/
--
Albert E. Whale aewhale@hky.com
http://www.hky.com/aewhale.html
------------------------------------------------------------------
Sr. Database, Internet and Unix Systems Consultant
Pennsylvania Parenthood Initiative - It takes two people to become
parents, the children need both of them!
http://www.geocities.com/Heartland/4688/papi.htm
Parents without Partners - Past President
Co-Founder of The Purple Heart Foundation
More information about the Gcc
mailing list