This is the mail archive of the gcc-patches@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]

Re: HAVE_GCC_VERSION fix


 > From: "Philippe De Muyter" <phdm@macqel.be>
 > 
 > Symptom :

 > **Error: /share/src/gnu/egcs-19991013/gcc/gansidecl.h: 44: syntax
 >      error (in preprocessor if)
 > 
 > 	* ansidecl.h (GCC_VERSION): New macro, replaces HAVE_GCC_VERSION.
 > 
 > --- ./include/ansidecl.h	Sun Oct 31 13:09:56 1999
 > +++ ./include/ansidecl.h	Sun Oct 31 13:09:31 1999
 > @@ -160,23 +160,31 @@
 >  
 >  #endif	/* ANSI C.  */
 >  
 > +#if 0 /* Using HAVE_GCC_VERSION(x,y) in #if does not work with older cpp's */
 >  /* This macro will return true if we are using gcc, and it is of a
 >     particular minimum version (both major & minor numbers are checked.)  */
 >  #ifndef HAVE_GCC_VERSION
 >  #define HAVE_GCC_VERSION(MAJOR, MINOR) \
 >    (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
 >  #endif /* ! HAVE_GCC_VERSION */
 > +#endif /* 0 */
 > +
 > +/* This macro simplifies testing if we are using gcc, and it is of a
 > +   particular minimum version (both major & minor numbers are checked.)  */
 > +#ifndef GCC_VERSION
 > +#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
 > +#endif /* GCC_VERSION */
 >  


	I believe the above macro will do the wrong thing for
__GNUC_MINOR__ > 99.  I know we can increase the multiplier, but
rather than have an arbitrary upper limit on __GNUC_MINOR__, I think
one of the following might be better.  I think the first one is
better, but might not work.  The second I believe must work.

Both have the advantage that you don't have to rename the macro and
update the callers.

Please let me know which one works for you.

		Thanks,
		--Kaveh


--- ansidecl.h~	Sun Oct 10 08:43:46 1999
+++ ansidecl.h	Sun Oct 31 12:00:11 1999
@@ -163,8 +163,8 @@ Foundation, Inc., 59 Temple Place - Suit
 /* This macro will return true if we are using gcc, and it is of a
    particular minimum version (both major & minor numbers are checked.)  */
 #ifndef HAVE_GCC_VERSION
-#define HAVE_GCC_VERSION(MAJOR, MINOR) \
-  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
+#define HAVE_GCC_VERSION(MAJOR, MINOR) (defined (__GNUC__) && \
+  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR))))
 #endif /* ! HAVE_GCC_VERSION */
 
 /* Define macros for some gcc attributes.  This permits us to use the



--- ansidecl.h~	Sun Oct 10 08:43:46 1999
+++ ansidecl.h	Sun Oct 31 11:59:11 1999
@@ -163,8 +163,13 @@ Foundation, Inc., 59 Temple Place - Suit
 /* This macro will return true if we are using gcc, and it is of a
    particular minimum version (both major & minor numbers are checked.)  */
 #ifndef HAVE_GCC_VERSION
+#ifdef __GNUC__
 #define HAVE_GCC_VERSION(MAJOR, MINOR) \
   (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
+#else /* ! __GNUC__ */
+/* Some older cpp's can't handle the above expression. */
+#define HAVE_GCC_VERSION 0
+#endif /* __GNUC__ */
 #endif /* ! HAVE_GCC_VERSION */
 
 /* Define macros for some gcc attributes.  This permits us to use the


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