This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch to libstdc++]: cheaders=c cstdarg/stdarg.h namespace control
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 26 Sep 2002 18:51:06 +1000 (EST)
- Subject: [Patch to libstdc++]: cheaders=c cstdarg/stdarg.h namespace control
The include/c/std_cstdarg.h and include/c-compatibility/stdarg.h pair of
headers
makes it difficult to keep std::va_list out of global namespace.
For example, with mingw32 build:
code that #includes <cstdio> does this this:
. D:/MINGW/include/c++/3.3/cstdio
.. D:/MINGW/include/stdio.h <<< defines __need__va_list
... D:/MINGW/include/c++/3.3/stdarg.h
.... D:/MINGW/include/c++/3.3/cstdarg
..... D:/MINGW/include/stdarg.h <<< mingw runtime header that fowards to...
...... D:/MINGW/lib/gcc-lib/mingw32/3.3/include/stdarg.h
The c-compatibility c++/3.3/stdarg.h included from stdio.h injects
va_list into global even though the user only includes a std C++
header and the C stdio.h header was careful to use __need__va_list to
only get __gnuc_va_list typedef.
The following patch changes the behaviour so that the va_list is
automatically injected into global _only_ if user code included <stdarg.h>
without a __need__va_list.
2002-09-26 Danny Smith <dannysmith@users.sourceforeg.net>
* include/c/std_cstdarg.h: Don't #undef __need__va_list.
* include/c_compatibility/stdarg.h: Inject va_list into global
only if code included stdarg.h without __need__va_list
Index: include/c/std_cstdarg.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c/std_cstdarg.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 std_cstdarg.h
*** include/c/std_cstdarg.h 20 Jun 2002 19:08:20 -0000 1.4
--- include/c/std_cstdarg.h 26 Sep 2002 08:39:28 -0000
***************
*** 36,42 ****
#pragma GCC system_header
- #undef __need___va_list
#include_next <stdarg.h>
#endif
--- 36,41 ----
Index: include/c_compatibility/stdarg.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_compatibility/stdarg.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 stdarg.h
*** include/c_compatibility/stdarg.h 21 Jun 2002 20:20:44 -0000 1.1
--- include/c_compatibility/stdarg.h 26 Sep 2002 08:39:28 -0000
***************
*** 32,37 ****
#include <cstdarg>
! using std::va_list;
#endif
--- 32,41 ----
#include <cstdarg>
! // If stdarg.h was included from user code, rather than from
! // stdio.h (with __need_va_list), inject into global namespace.
! #if defined (_STDARG_H) || defined _ANSI_STDARG_H_
! using std::va_list
! #endif
#endif
http://mobile.yahoo.com.au - Yahoo! Messenger for SMS
- Always be connected to your Messenger Friends