This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFDiscussion: Macros used throughout gcc but not defined anywhere
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: zack at codesourcery dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 12 Jun 2002 23:10:21 -0400 (EDT)
- Subject: Re: RFDiscussion: Macros used throughout gcc but not defined anywhere
- References: <20020613001207.GA10917@codesourcery.com>
Zack,
First, thanks for doing these kinds of cleanups! :-)
Onto my feedback. For many of these, it's possible that some checks
of a macro are legit while other checks of the same macro are bogus or
unnecessary. E.g.:
>ANSI_PROTOTYPES
legit:
system.h <global> 32 #ifdef ANSI_PROTOTYPES
probably unnecessary:
scan.h <global> 37 #if defined(ANSI_PROTOTYPES) || defined(__cplusplus)
I'm not sure why scan.h provides its own _PARAMS instead of using
ansidecl.h's PARAMS like everyone else.
config/m88k/m88k-protos.h <global> 74 #ifdef ANSI_PROTOTYPES
system.h <global> 338 #ifdef ANSI_PROTOTYPES
system.h <global> 349 #ifdef ANSI_PROTOTYPES
These are checked to see if we can say "struct foo;" before using
`foo' in a prototype. I think "struct foo;" is valid even in
traditional C compilers (at least the ones still in use.) We do naked
"struct foo;" in other files in the compiler, so the wrapper is not
necessary.
--------------------
It's pretty clear that these below are ways of checking whether we've
got stdio.h before using FILE in a decl. Now that everybody uses
system.h (which gets us stdio.h) we probably don't need these. If we
decide to keep these checks, I think BUFSIZ was the preferred method
rather than the cris method of checking 5 other things. But I bet
they could go.
>BUFSIZ
config/i386/cygwin.h <global> 443 #ifndef BUFSIZ
[...]
>FILE
config/cris/cris-protos.h <global> 24 #if defined(FILE) || defined(stdin) || defined(stdout) || defined(getc) || defined(putc)
>getc
config/cris/cris-protos.h <global> 24 #if defined(FILE) || defined(stdin) || defined(stdout) || defined(getc) || defined(putc)
--------------------
>HAHA
>HOHO
hee hee! Never know what you'll find buried in gcc. :-)
--------------------
>atexit
tsystem.h <global> 50 #ifndef atexit
tsystem.h <global> 51 extern int atexit (void (*)(void ));
>free
tsystem.h <global> 46 #ifndef free
tsystem.h <global> 47 extern void free (void *);
>getrlimit
system.h <global> 337 #ifndef getrlimit
system.h <global> 341 extern int getrlimit PARAMS ((int , struct rlimit *));
>setrlimit
system.h <global> 348 #ifndef setrlimit
system.h <global> 352 extern int setrlimit PARAMS ((int , const struct rlimit *));
>strsignal
system.h <global> 330 #ifndef strsignal
system.h <global> 331 extern const char *strsignal PARAMS ((int ));
I probably added most of the above. They are all just double checking
that no header defined the token as a macro before prototyping it. I
recall someone (Jeff?) verified that at least some of these were
actually necessary on some (now ancient) platforms.
Oh here it is in the search engine. Flashback to two years ago, with
you and me and Jeff having the exact same discussion... :-)
http://gcc.gnu.org/ml/gcc-patches/2000-02/msg00790.html
The index one below was definitely necessary on systems that defined
index to strchr and also had system header structures that had fields
called index. (See the comment above line 663.) Silly, but true.
>index
mips-tdump.c <global> 26 #ifdef index
mips-tdump.c <global> 27 #undef index
mips-tfile.c <global> 663 #undef index