This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Projects for beginners
- To: zackw at Stanford dot EDU
- Subject: Re: Projects for beginners
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Mon, 12 Mar 2001 23:02:05 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org, jsm28 at cam dot ac dot uk, neil at daikokuya dot demon dot co dot uk
> From: "Zack Weinberg" <zackw@Stanford.EDU>
>
> The sentence beginning "this is useful..." is really awkward. Something
> like
>
> This means that if you poison an identifier, you need not worry
> about system headers defining macros that use it. For instance,
> if your system headers define @code{memcpy} in terms of the BSD
> @code{bcopy} function, it is still safe to poison @code{bcopy}.
>
> would be clearer, IMO - it needs a bit of work to tie it into the
> surrounding text.
> zw
IMHO, your example text regarding memcpy/bcopy simply repeated what I
showed in the rindex/strrchr example. So I rearranged it a bit and
merged the two. Here's what I've got now.
OK for head and branch?
--Kaveh
2001-03-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cpp.texi (poison): Explain the macro expansion exception.
diff -rup orig/egcs-CVS20010312/gcc/cpp.texi egcs-CVS20010312/gcc/cpp.texi
--- orig/egcs-CVS20010312/gcc/cpp.texi Sat Mar 3 06:32:32 2001
+++ egcs-CVS20010312/gcc/cpp.texi Mon Mar 12 22:42:21 2001
@@ -1601,6 +1601,22 @@ sprintf(some_string, "hello");
@noindent
will produce an error.
+Note, if the poisoned identifier appears through the result of macro
+expansion it @emph{won't} cause an error. So if you poison an
+identifier you need not worry about system headers defining macros that
+use it.
+
+For example,
+
+@example
+#define strrchr rindex
+#pragma GCC poison rindex
+strrchr(some_string, 'h');
+@end example
+
+@noindent
+will not produce an error.
+
@node Macro Pitfalls,, Poisoning, Macros
@subsection Pitfalls and Subtleties of Macros
@cindex problems with macros