cpp_reader *pfile;
enum c_lang lang;
{
- struct cpp_pending *pend = CPP_OPTION (pfile, pending);
-
/* Defaults. */
CPP_OPTION (pfile, lang) = lang;
CPP_OPTION (pfile, objc) = 0;
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 1;
- new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
break;
case CLK_GNUC89:
CPP_OPTION (pfile, trigraphs) = 0;
/* ISO C. */
case CLK_STDC94:
- new_pending_directive (pend, "__STDC_VERSION__=199409L", cpp_define);
case CLK_STDC89:
CPP_OPTION (pfile, trigraphs) = 1;
CPP_OPTION (pfile, dollars_in_ident) = 0;
CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, extended_numbers) = 0;
- new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
break;
case CLK_STDC99:
CPP_OPTION (pfile, trigraphs) = 1;
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 1;
- new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
- new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
break;
/* Objective C. */
case CLK_OBJCXX:
- new_pending_directive (pend, "__cplusplus", cpp_define);
CPP_OPTION (pfile, cplusplus) = 1;
case CLK_OBJC:
CPP_OPTION (pfile, trigraphs) = 0;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 0;
CPP_OPTION (pfile, objc) = 1;
- new_pending_directive (pend, "__OBJC__", cpp_define);
break;
/* C++. */
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 1;
CPP_OPTION (pfile, c99) = 0;
- new_pending_directive (pend, "__cplusplus", cpp_define);
break;
/* Assembler. */
CPP_OPTION (pfile, cplusplus_comments) = 1;
CPP_OPTION (pfile, digraphs) = 0;
CPP_OPTION (pfile, c99) = 0;
- new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
break;
}
}
pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
+ set_lang (pfile, lang);
CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, discard_comments) = 1;
CPP_OPTION (pfile, show_column) = 1;
CPP_OPTION (pfile, pending) =
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
- /* After creating pfile->pending. */
- set_lang (pfile, lang);
-
/* It's simplest to just create this struct whether or not it will
be needed. */
pfile->deps = deps_init ();
_cpp_define_builtin (pfile, str);
}
}
+
+ if (CPP_OPTION (pfile, cplusplus))
+ _cpp_define_builtin (pfile, "__cplusplus 1");
+ if (CPP_OPTION (pfile, objc))
+ _cpp_define_builtin (pfile, "__OBJC__ 1");
+
+ if (CPP_OPTION (pfile, lang) == CLK_STDC94)
+ _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
+ else if (CPP_OPTION (pfile, c99))
+ _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
+
+ if (CPP_OPTION (pfile, lang) == CLK_STDC89
+ || CPP_OPTION (pfile, lang) == CLK_STDC94
+ || CPP_OPTION (pfile, lang) == CLK_STDC99)
+ _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
+ else if (CPP_OPTION (pfile, lang) == CLK_ASM)
+ _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
}
#undef BUILTIN
#undef OPERATOR