Article View: gnu.gcc.bug
Article #6260Feature request for GNU cpp
From: christopher (c.j.) rath
Date: Thu, 28 Dec 1995 00:00
Date: Thu, 28 Dec 1995 00:00
71 lines
2164 bytes
2164 bytes
/*****
*****
**
** This code demonstrates cpp behaviour that I would like to see
** cpp emit a warning message for. When a #define over-rides an
** enum, I would like cpp to warn me about what is taking place.
** This should only be enabled by specific user request, or by
** ``gcc -Wall''.
**
** This code appears to compile alright, but it will never
** execute as I had intended (because the enum's value is 0 and
** the #define's value is 1). Unfortunately, this problem is
** hard to find when it is one of the system header files that is
** over-riding an enum in my own code.
**
*****
*****/
typedef enum {
OK,
NOTOK
} okType;
#define OK (1)
okType main() {
okType imok = OK;
/* lots of code that may conditionally set imok to NOTOK */
if (imok == NOTOK) {
printf("Premature return\n.");
return imok;
} else {
printf("Returned properly\n.");
}
return imok;
}
/***** Here's what ``gcc -E'' emits for this code (with empty lines removed): *****
#1 "hassle.c"
typedef enum {
OK ,
NOTOK
} okType ;
okType main ( )
{
okType imok = ( 1 ) ;
if ( imok == NOTOK ) {
printf ( "Premature return\n." ) ;
return imok ;
} else {
printf ( "Returned properly\n." ) ;
}
return imok ;
}
***** end of ``gcc -E'' output *****/
--
=== Christopher Rath ===== crath@bnr.ca ===== (613) 765-3141 ===
Bell-Northern Research |
Box 3511, Station `C' | ``Hydrogen is a colourless, odourless
Ottawa, ON K1Y 4H7 | gas which, given enough time, turns
FAX: (613) 763-4101 | into people.'' --- Henry Hiebert
Technical Details
Message-ID:
<CRATH.95Dec28133838@bmerhe83.bnr.ca>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,ba0387e231e149de,start X-Google-Attributes: gid113d02,public From: crath@bnr.ca (christopher (c.j.) rath) Subject: Feature request for GNU cpp Date: 1995/12/28 Message-ID: <CRATH.95Dec28133838@bmerhe83.bnr.ca> X-Deja-AN: 123052122 distribution: gnu sender: daemon@cis.ohio-state.edu organization: Bell Northern Research, Ottawa, Canada newsgroups: gnu.gcc.bug