Commit 6e270179 by Neil Booth

c-cppbuiltin.c (c_cpp_builtins): Move __STDC_HOSTED__ into cpplib as it's a…

c-cppbuiltin.c (c_cpp_builtins): Move __STDC_HOSTED__ into cpplib as it's a Standard Predefined Macro.

	* 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.
	* cppfiles.c (find_or_create_entry): Preserve errno.

From-SVN: r66688
parent 8af992ea
2003-05-11 Bruno Haible <bruno@clisp.org>
* cppfiles.c (find_or_create_entry): Preserve errno.
2003-05-11 Neil Booth <neil@cat.daikokuya.co.uk>
* 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.
2003-05-11 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR C++/689
......
......@@ -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)
......
......@@ -1789,7 +1789,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++)
......
......@@ -174,8 +174,10 @@ find_or_create_entry (pfile, fname)
splay_tree_node node;
struct include_file *file;
char *name = xstrdup (fname);
int saved_errno;
cpp_simplify_path (name);
saved_errno = errno;
node = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) name);
if (node)
free (name);
......@@ -184,7 +186,7 @@ find_or_create_entry (pfile, fname)
file = xcnew (struct include_file);
file->name = name;
file->header_name = name;
file->err_no = errno;
file->err_no = saved_errno;
node = splay_tree_insert (pfile->all_include_files,
(splay_tree_key) file->name,
(splay_tree_value) file);
......
......@@ -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);
......@@ -355,6 +357,11 @@ cpp_init_builtins (pfile)
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");
}
......
......@@ -526,7 +526,7 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
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,
......
......@@ -264,15 +264,14 @@ complete support for international character sets in a future release.
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 undefine them.
@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 this macro to @code{199711L}. The
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
......@@ -1913,11 +1920,6 @@ calculate a single number, then compare that against a threshold:
@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
testing @code{@w{(__GNUC__ && __cplusplus)}}.
......
......@@ -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
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment