+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
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)
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++)
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);
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);
}
/* 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);
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");
}
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,
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
@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.
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
@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)}}.
@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
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. */