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]

-D_ANSI_C_SOURCE on AIX


The following code snippet, by Geoff Keating, is valid ANSI/ISO C, 
however it does not compile on AIX 4.* because stdio.h includes
sys/limits.h that includes float.h that defines FLT_RADIX.

#include <stdio.h>
enum { FLT_RADIX = 30; }
int foo(void) { return FLT_RADIX; }

One simple way to fix this is to define _ANSI_C_SOURCE, that prevents
sys/limits.h from including float.h.  So I arranged for -ansi to
define _ANSI_C_SOURCE, just like it defines __STRICT_ANSI__ for GNU
libc to enable strict ANSI/ISO compliance.  There are two separate
patch files.  The second applies only to the newppc branch; while
first applies to mainline and the branch.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
	
	* config/rs6000/aix41.h (CPP_SPEC): Define _ANSI_C_SOURCE if -ansi
	is given.
	* config/rs6000/aix43.h (CPP_SPEC): Likewise.

Index: gcc/config/rs6000/aix41.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/aix41.h,v
retrieving revision 1.8
diff -u -r1.8 aix41.h
--- gcc/config/rs6000/aix41.h	2000/02/26 21:36:40	1.8
+++ gcc/config/rs6000/aix41.h	2000/03/15 01:25:46
@@ -76,6 +76,7 @@
 
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
+   %{ansi: -D_ANSI_C_SOURCE}\
    %{mpe: -I/usr/lpp/ppe.poe/include}\
    %{mthreads: -D_THREAD_SAFE}\
    %(cpp_cpu)"
Index: gcc/config/rs6000/aix43.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/aix43.h,v
retrieving revision 1.9
diff -u -r1.9 aix43.h
--- gcc/config/rs6000/aix43.h	2000/01/07 18:33:12	1.9
+++ gcc/config/rs6000/aix43.h	2000/03/15 01:25:47
@@ -104,6 +104,7 @@
 
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
+   %{ansi: -D_ANSI_C_SOURCE}\
    %{maix64: -D__64BIT__ -D_ARCH_PPC}\
    %{mpe: -I/usr/lpp/ppe.poe/include}\
    %{mthreads: -D_THREAD_SAFE}\
Index: gcc/config/rs6000/ChangeLog
from  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
	
	* rs6000.h (CPP_SPEC): Moved to...
	* aix.h: then modified likewise.
	
Index: gcc/config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.64.2.21
diff -u -r1.64.2.21 rs6000.h
--- gcc/config/rs6000/rs6000.h	2000/03/06 18:01:52	1.64.2.21
+++ gcc/config/rs6000/rs6000.h	2000/03/15 01:40:27
@@ -42,11 +42,6 @@
 #define TARGET_CPU_DEFAULT ((char *)0)
 #endif
 
-/* Define appropriate architecture macros for preprocessor depending on
-   target switches.  */
-
-#define CPP_SPEC "%{posix: -D_POSIX_SOURCE} %(cpp_cpu)"
-
 /* Common CPP definitions used by CPP_SPEC among the various targets
    for handling -mcpu=xxx switches.  */
 #define CPP_CPU_SPEC \
Index: gcc/config/rs6000/aix.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/rs6000/Attic/aix.h,v
retrieving revision 1.1.2.11
diff -u -r1.1.2.11 aix.h
--- gcc/config/rs6000/aix.h	2000/02/29 22:35:42	1.1.2.11
+++ gcc/config/rs6000/aix.h	2000/03/15 01:40:27
@@ -66,6 +66,13 @@
 #define CPP_PREDEFINES "-D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_LONG_LONG \
 -Asystem(unix) -Asystem(aix) -Acpu(rs6000) -Amachine(rs6000)"
 
+/* Define appropriate architecture macros for preprocessor depending on
+   target switches.  */
+
+#define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
+   %{ansi: -D_ANSI_C_SOURCE}\
+   %(cpp_cpu)"
+
 /* Tell the assembler to assume that all undefined names are external.
 
    Don't do this until the fixed IBM assembler is more generally available.

-- 
Alexandre Oliva     http://www.ic.unicamp.br/~oliva/     Enjoy Guaranį
Cygnus Solutions, a Red Hat company        aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist    CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org}   Write to mailing lists, not to me

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