[NTLUG:Discuss] gcc 3.0.1

Steve Baker sjbaker1 at airmail.net
Sat Sep 8 20:24:35 CDT 2001


Richard Cobbe wrote:

> > It's a lot pickier about some trivial things - one that annoys me is that
> > it complains if a file does not end with a newline!
> 
> Does it really?  That's moderately surprising.  I know a number of older
> Unix tools tend to balk at such files, but I can't see why gcc would care.

I think it's just trying to be helpful and tell you when (perhaps) the
file gets somehow truncated or something.

> A quick glance at the C++ spec suggests that this is not a formal
> requirement, but at over 700 pages, I may well have missed something.

Well, warning messages are not in the C++ spec.
 
> Oh, well; it's easy enough to fix:
> 
> (setq require-final-newline t)

...unless you have a million lines of C++ code spread over some 3,000 files
as I have!  I had to write a program to remove all trailing white-space from
a source file and append a newline...then I just ran that on all my sources.

> > I think all the significant new messages are warnings - but I always go
> > by the rule "Warnings are Errors too".
> 
> In general, I use that guideline as well.  It's somewhat annoying, however,
> that gcc does not, to my knowledge, provide a mechanism to disable specific
> warnings for certain locations in a program.  MSVC++ has something like
> this; I don't remember the syntax exactly, but I think it's something along
> the lines of
> 
> #pragma disable 2423
> ...
> #pragma enable 2423
> 
> where 2423 is the warning number that you can look up in their docs.

The problem with that is twofold:  Firstly, those warning numbers are
not standardized and "Warning 2423" in one version of the compiler may
be something you want to disable - but be "Uninitialise variable" or
suchlike that you care passionately about in some other version.

Secondly, the effect of a '#pragma' is completely system-specific - which
means that you often need:

#ifdef WIN32
#pragma disable 2423
#else
#ifdef IRIX
#pragma disable 1234
#else
....

Pragma's annoy the GCC team no end. I'm told that there was once a
version of GCC that would start 'nethack' running whenever it encountered
a '#pragma' on the grounds that this was a perfectly legitimate 'system
specific' action.

> Does GCC 3 have anything like this?  I know the GCC folks don't like
> pragmas much, but is there perhaps another mechanism which provides the
> same basic functionality?

I think you can turn off specific warnings on the command line - but that
just makes your build infrastructure non-portable instead.

In the end, I just do whatever it takes to make the warning 'go away' by
changing the code - even if this occasionally requires me to edit a few
thousand files!

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1 at airmail.net>   WorkMail: <sjbaker at link.com>
URLs : http://web2.airmail.net/sjbaker1
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net




More information about the Discuss mailing list