This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

CPP inconsistency


  Hi,

  Just a minor thing, but I hit this problem times to times, I know
 the CPP preprocessor has no warning like "end of line ignored"...
 GCC-3.3.5 and 3.4.3.

etienne@cygne:~/projet$ cat > tmp.c
#define OPTION1 0x0001
#define OPTION2 0x0002
#define OPTION3 0x0004
#define OPTION4 0x0008

#define CONFIGURATION (OPTION1 | OPTION3)

#if CONFIGURATION & OPTION1
#warning OPTION1 set
#endif

#if CONFIGURATION & OPTION2
#warning OPTION2 set
#endif

#if CONFIGURATION & OPTION3
#warning OPTION3 set
#endif

#if CONFIGURATION & OPTION4
#warning OPTION4 set
#endif

#if !(CONFIGURATION & OPTION2)
#warning OPTION2 unset
#endif

#if (CONFIGURATION & OPTION2) == 0
#warning OPTION2 unset
#endif

// There is the problem: the "== 0" is ignored
#if CONFIGURATION & OPTION2 == 0
#warning OPTION2 unset
#else
#warning OPTION2 set
#endif

etienne@cygne:~/projet$ gcc -E tmp.c
# 1 "tmp.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "tmp.c"
tmp.c:9:2: warning: #warning OPTION1 set
tmp.c:17:2: warning: #warning OPTION3 set
tmp.c:25:2: warning: #warning OPTION2 unset
tmp.c:29:2: warning: #warning OPTION2 unset
tmp.c:36:2: warning: #warning OPTION2 set

  Etienne.


	

	
		
__________________________________________________________________
Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails ! 
Créez votre Yahoo! Mail sur http://fr.mail.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]