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]

Patch: Re: glimits.h is not compatible with -traditional


>  > The warning results from defines in glimits.h that are not compatible with
>  > -traditional.  For example,
>  > 
>  > #define UINT_MAX (INT_MAX * 2U + 1)
>  > 
>  > There are also various C99 defines in glimits.h which are not compatible
>  > with -traditional (long long stuff).  I think these need to be surrounded
>  > by appropriate ifdef __STDC__'s.

The enclosed patch makes glimits.h compatible with -traditional.  The
warnings still happen but they are now bogus since the `U' defines aren't
used if __STDC__ isn't defined.

It is not possible to use the traditional defines in cpp expressions
because casts aren't supported.  However, cpp expressions aren't part
of traditional C.  Thus, this doesn't appear to be a problem.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2000-09-01  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* glimits.h:  Make compatible with `-traditional'.

--- glimits.h.orig	Thu Jul 20 20:47:27 2000
+++ glimits.h	Fri Sep  1 14:46:27 2000
@@ -59,7 +59,11 @@
 
 /* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */
 #undef UINT_MAX
+#ifdef __STDC__
 #define UINT_MAX (INT_MAX * 2U + 1)
+#else
+#define UINT_MAX ((unsigned)INT_MAX * 2 + 1)
+#endif
 
 /* Minimum and maximum values a `signed long int' can hold.
    (Same as `int').  */
@@ -77,8 +81,13 @@
 
 /* Maximum value an `unsigned long int' can hold.  (Minimum is 0).  */
 #undef ULONG_MAX
+#ifdef __STDC__
 #define ULONG_MAX (LONG_MAX * 2UL + 1)
+#else
+#define ULONG_MAX ((unsigned long)LONG_MAX * 2 + 1)
+#endif
 
+#ifdef __STDC__
 #ifndef __LONG_LONG_MAX__
 #define __LONG_LONG_MAX__ 9223372036854775807LL
 #endif
@@ -106,6 +115,7 @@
 #undef ULONG_LONG_MAX
 #define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
 #endif
+#endif
 
 #endif /* _MACH_MACHLIMITS_H_ */
 #endif /* _LIMITS_H___ */

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