diff options
author | Geoff Keating <geoffk@cygnus.com> | 1999-09-09 04:00:37 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 1999-09-09 04:00:37 +0000 |
commit | fc009f966c98317401b51127f59de4ad37bb7d19 (patch) | |
tree | adfb849ae0813b5bacab43fb7a7ab5ec23bc7fb6 /gcc/cpp.texi | |
parent | d60f72aec57414b8339eecb25c33b423af7e6946 (diff) | |
download | gcc-fc009f966c98317401b51127f59de4ad37bb7d19.zip gcc-fc009f966c98317401b51127f59de4ad37bb7d19.tar.gz gcc-fc009f966c98317401b51127f59de4ad37bb7d19.tar.bz2 |
Makefile.in (cppexp.o): Depend on cpphash.h.
* Makefile.in (cppexp.o): Depend on cpphash.h.
* cppexp.c (cpp_lex): Handle `defined (xxx)' for poisoned xxx.
Include cpphash.h.
* cpphash.c (special_symbol): Handle plain `xxx' for poisoned xxx.
* cpplib.c (do_define): Generalise to handle poisoned definitions,
redefining poisoned identifiers, etc.
(do_undef): Don't allow poisoned identifiers to be undefined.
(do_pragma): Add #pragma poison.
(do_xifdef): Handle `#ifdef xxx' for poisoned xxx.
* cccp.c: Add T_POISON node type.
(special_symbol): Handle `defined(xxx)' and plain `xxx' for
poisoned xxx.
(do_define): Generalise to handle poisoned definitions,
redefining poisoned identifiers, etc.
(do_undef): Don't allow poisoned identifiers to be undefined.
(do_pragma): Add #pragma poison.
(do_xifdef): Handle `#ifdef xxx' for poisoned xxx.
* c-pragma.c (handle_pragma_token): Ignore #pragma poison.
* c-pragma.h: Add ps_poison state. We now always have generic
pragmas.
From-SVN: r29224
Diffstat (limited to 'gcc/cpp.texi')
-rw-r--r-- | gcc/cpp.texi | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/cpp.texi b/gcc/cpp.texi index e9a9095..5751722 100644 --- a/gcc/cpp.texi +++ b/gcc/cpp.texi @@ -551,6 +551,7 @@ in the C preprocessor. * Concatenation:: Building tokens from parts taken from macro arguments. * Undefining:: Cancelling a macro's definition. * Redefining:: Changing a macro's definition. +* Poisoning:: Ensuring a macro is never defined or used. * Macro Pitfalls:: Macros can confuse the unwary. Here we explain several common problems and strange features. @end menu @@ -1370,7 +1371,7 @@ The same form of @samp{#undef} directive will cancel definitions with arguments or definitions that don't expect arguments. The @samp{#undef} directive has no effect when used on a name not currently defined as a macro. -@node Redefining, Macro Pitfalls, Undefining, Macros +@node Redefining, Poisoning, Undefining, Macros @subsection Redefining Macros @cindex redefining macros @@ -1404,7 +1405,28 @@ where there was no whitespace at all. Recall that a comment counts as whitespace. -@node Macro Pitfalls,, Redefining, Macros +@node Poisoning, Macro Pitfalls, Redefining, Macros +@subsection Poisoning Macros +@cindex poisoning macros + +Sometimes, there is an identifier that you want to remove completely +from your program, and make sure that it never creeps back in. To +enforce this, the @samp{#pragma poison} directive can be used. +@samp{#pragma poison} is followed by a list of identifiers to poison, +and takes effect for the rest of the source. You cannot @samp{#undef} a +poisoned identifier or test to see if it's defined with @samp{#ifdef}. + +For example, + +@example +#pragma poison printf sprintf fprintf +sprintf(some_string, "hello"); +@end example + +@noindent +will produce an error. + +@node Macro Pitfalls,, Poisoning, Macros @subsection Pitfalls and Subtleties of Macros @cindex problems with macros @cindex pitfalls of macros |