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: AIX vs. const



As mentioned a while back, Bison defines away const if neither
__STDC__ nor __cplusplus is defined.  If the rest of the GCC headers
fail to match that behavior, we get type clashses that some versions
of IBM's C compiler issue hard errors about.  There's no real harm in
defining away const; we just lose some type-checking on platforms
where the compiler doesn't define __STDC__.

This patch does the obvious thing to be compatible with Bison.

Tested on powerpc-ibm-aix4.3.2.0.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-01-25  Mark Mitchell  <mark@codesourcery.com>

	* acconfig.h: Define `const' to the empty string if neither
	__STDC__ nor __cplusplus is defined.
	* config.in: Regenerated.

Index: gcc/acconfig.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/acconfig.h,v
retrieving revision 1.49
diff -c -p -r1.49 acconfig.h
*** acconfig.h	2000/05/27 22:05:01	1.49
--- acconfig.h	2001/01/25 21:46:25
***************
*** 25,27 ****
--- 25,41 ----
  
  /* Define to `int' if <sys/types.h> doesn't define.  */
  #undef ssize_t
+ 
+ @BOTTOM@
+ 
+ /* Bison unconditionally undefines `const' if neither `__STDC__' nor
+    __cplusplus are defined.  That's a problem since we use `const' in
+    the GCC headers, and the resulting bison code is therefore type
+    unsafe.  Thus, we must match the bison behavior here.  */
+ 
+ #ifndef __STDC__
+ #ifndef __cplusplus
+ #undef const
+ #define const
+ #endif
+ #endif
Index: gcc/config.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config.in,v
retrieving revision 1.93
diff -c -p -r1.93 config.in
*** config.in	2001/01/21 01:51:41	1.93
--- config.in	2001/01/25 21:46:25
***************
*** 452,454 ****
--- 452,466 ----
  /* Define to 1 if you want to enable namespaces (-fhonor-std) by default. */
  #undef ENABLE_STD_NAMESPACE
  
+ 
+ /* Bison unconditionally undefines `const' if neither `__STDC__' nor
+    __cplusplus are defined.  That's a problem since we use `const' in
+    the GCC headers, and the resulting bison code is therefore type
+    unsafe.  Thus, we must match the bison behavior here.  */
+ 
+ #ifndef __STDC__
+ #ifndef __cplusplus
+ #undef const
+ #define const
+ #endif
+ #endif

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