This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: Update docs, make __STDC_HOSTED__ a Standard Macro
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Andreas Jaeger <aj at suse dot de>
- Date: Sun, 11 May 2003 14:34:22 +0100
- Subject: cpplib: Update docs, make __STDC_HOSTED__ a Standard Macro
Andreas noticed the docs for -undef weren't clear. In clarifying
them, I noticed we were treating __STDC_HOSTED__ incorrectly.
Neil.
* c-cppbuiltin.c (c_cpp_builtins): Move __STDC_HOSTED__ into
cpplib as it's a Standard Predefined Macro.
* c-opts.c (finish_options): Pass flag_hosted to cpp_init_builtins.
* cppinit.c (_cpp_init_builtins): Take HOSTED. Define
__STDC_HOSTED__ appropriately.
* cpplib.h (_cpp_init_builtins): Update.
* fix-header.c (read_scan_file): Update.
* doc/cpp.texi, doc/cppopts.texi: Update documentation.
Index: c-cppbuiltin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-cppbuiltin.c,v
retrieving revision 1.7
diff -u -p -r1.7 c-cppbuiltin.c
--- c-cppbuiltin.c 15 Mar 2003 13:43:24 -0000 1.7
+++ c-cppbuiltin.c 10 May 2003 15:00:22 -0000
@@ -355,11 +355,6 @@ c_cpp_builtins (pfile)
if (optimize)
cpp_define (pfile, "__OPTIMIZE__");
- if (flag_hosted)
- cpp_define (pfile, "__STDC_HOSTED__=1");
- else
- cpp_define (pfile, "__STDC_HOSTED__=0");
-
if (fast_math_flags_set_p ())
cpp_define (pfile, "__FAST_MATH__");
if (flag_really_no_inline)
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.43
diff -u -p -r1.43 c-opts.c
--- c-opts.c 6 May 2003 20:42:32 -0000 1.43
+++ c-opts.c 10 May 2003 15:00:23 -0000
@@ -1790,7 +1790,7 @@ finish_options ()
size_t i;
cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
- cpp_init_builtins (parse_in);
+ cpp_init_builtins (parse_in, flag_hosted);
c_cpp_builtins (parse_in);
cpp_change_file (parse_in, LC_RENAME, _("<command line>"));
for (i = 0; i < deferred_count; i++)
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.277
diff -u -p -r1.277 cppinit.c
--- cppinit.c 4 May 2003 20:03:54 -0000 1.277
+++ cppinit.c 10 May 2003 15:00:23 -0000
@@ -327,10 +327,12 @@ mark_named_operators (pfile)
}
/* Read the builtins table above and enter them, and language-specific
- macros, into the hash table. */
+ macros, into the hash table. HOSTED is true if this is a hosted
+ environment. */
void
-cpp_init_builtins (pfile)
+cpp_init_builtins (pfile, hosted)
cpp_reader *pfile;
+ int hosted;
{
const struct builtin *b;
size_t n = ARRAY_SIZE (builtin_array);
@@ -354,6 +356,11 @@ cpp_init_builtins (pfile)
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
else if (CPP_OPTION (pfile, c99))
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
+
+ if (hosted)
+ cpp_define (pfile, "__STDC_HOSTED__=1");
+ else
+ cpp_define (pfile, "__STDC_HOSTED__=0");
if (CPP_OPTION (pfile, objc))
_cpp_define_builtin (pfile, "__OBJC__ 1");
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.253
diff -u -p -r1.253 cpplib.h
--- cpplib.h 23 Apr 2003 22:43:58 -0000 1.253
+++ cpplib.h 10 May 2003 15:00:23 -0000
@@ -526,7 +526,7 @@ extern void cpp_set_callbacks PARAMS ((c
extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *));
/* Set up built-ins like __FILE__. */
-extern void cpp_init_builtins PARAMS ((cpp_reader *));
+extern void cpp_init_builtins PARAMS ((cpp_reader *, int));
/* Call this to finish preprocessing. If you requested dependency
generation, pass an open stream to write the information to,
Index: fix-header.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fix-header.c,v
retrieving revision 1.94
diff -u -p -r1.94 fix-header.c
--- fix-header.c 19 Apr 2003 00:22:49 -0000 1.94
+++ fix-header.c 10 May 2003 15:00:24 -0000
@@ -636,7 +636,7 @@ read_scan_file (in_fname, argc, argv)
exit (FATAL_EXIT_CODE);
cpp_change_file (scan_in, LC_RENAME, "<built-in>");
- cpp_init_builtins (scan_in);
+ cpp_init_builtins (scan_in, true);
cpp_change_file (scan_in, LC_RENAME, in_fname);
/* Process switches after builtins so -D can override them. */
Index: doc/cpp.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cpp.texi,v
retrieving revision 1.55
diff -u -p -r1.55 cpp.texi
--- doc/cpp.texi 4 May 2003 20:03:54 -0000 1.55
+++ doc/cpp.texi 10 May 2003 15:00:26 -0000
@@ -264,15 +264,14 @@ complete support for international chara
Different systems use different conventions to indicate the end of a
line. GCC accepts the ASCII control sequences @kbd{LF}, @kbd{@w{CR
-LF}}, @kbd{CR}, and @kbd{@w{LF CR}} as end-of-line markers. The first
-three are the canonical sequences used by Unix, DOS and VMS, and the
+LF}}, @kbd{CR} as end-of-line markers. These
+are the canonical sequences used by Unix, DOS and VMS, and the
classic Mac OS (before OSX) respectively. You may therefore safely copy
source code written on any of those systems to a different one and use
it without conversion. (GCC may lose track of the current line number
if a file doesn't consistently use one convention, as sometimes happens
when it is edited on computers with different conventions that share a
-network file system.) @kbd{@w{LF CR}} is included because it has been
-reported as an end-of-line marker under exotic conditions.
+network file system.)
If the last line of any input file lacks an end-of-line marker, the end
of the file is considered to implicitly supply one. The C standard says
@@ -1733,7 +1732,7 @@ predefined macros, but you cannot undefi
@subsection Standard Predefined Macros
@cindex standard predefined macros.
-The standard predefined macros are specified by the C and/or C++
+The standard predefined macros are specified by the relevant
language standards, so they are available with all compilers that
implement those standards. Older compilers may not provide all of
them. Their names all start with double underscores.
@@ -1852,6 +1851,14 @@ of the 1998 C++ standard will define thi
GNU C++ compiler is not yet fully conforming, so it uses @code{1}
instead. We hope to complete our implementation in the near future.
+@item __OBJC__
+This macro is defined, with value 1, when the Objective-C compiler is in
+use. You can use @code{__OBJC__} to test whether a header is compiled
+by a C compiler or a Objective-C compiler.
+
+@item __ASSEMBLER__
+This macro is defined with value 1 when preprocessing assembler.
+
@end table
@node Common Predefined Macros
@@ -1912,11 +1919,6 @@ calculate a single number, then compare
@noindent
Many people find this form easier to understand.
-
-@item __OBJC__
-This macro is defined, with value 1, when the Objective-C compiler is in
-use. You can use @code{__OBJC__} to test whether a header is compiled
-by a C compiler or a Objective-C compiler.
@item __GNUG__
The GNU C++ compiler defines this. Testing it is equivalent to
Index: doc/cppopts.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/cppopts.texi,v
retrieving revision 1.21
diff -u -p -r1.21 cppopts.texi
--- doc/cppopts.texi 4 May 2003 22:06:57 -0000 1.21
+++ doc/cppopts.texi 10 May 2003 15:00:26 -0000
@@ -40,8 +40,11 @@ provided with a @option{-D} option.
@item -undef
@opindex undef
-Do not predefine any system-specific macros. The common predefined
-macros remain defined.
+Do not predefine any system-specific or GCC-specific macros. The
+standard predefined macros remain defined.
+@ifset cppmanual
+@xref{Standard Predefined Macros}
+@end ifset
@item -I @var{dir}
@opindex I