This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH [mingw32]: By default. don't pollute libstdc++ with win32api names


Hello,

The attached patch for mingw protects code that uses libstdc++ from
pollution by the huge number of symbol names amd macros found in the
win32api.

Not defining __GTHREAD_HIDE_WIN32API has resulted in numerous
parse error bug reports to mingw maling list due to conflicts of
unrequested windows defines with user code names
 
The NOMINMAX is a win32 define that keeps windef.h from defining
min and max as macros. If windows.h (and hence windef.h) is included
before a libstdc++ header, there is no problem because stl_algobase.h
takes care to undef the macros. The problem arise if windows.h is included
after stl_algobase.h defines min and max as functions.

Booted, tested with i686-pc-mingw on trunk and branch

AFAICT fromn config.gcc, mingw is the only platform that uses win32
thread model by default. 

Danny

ChangeLog

	* gthr-win32.h (__GTHREAD_HIDE_WIN32API): Test for non-zero
	value, not just if defined.
	
libstdc++-v3/ChangeLog

	* config/os/mingw32/os_defines.h (__GTHREAD_HIDE_WIN32API):
	Define to 1 by defualt.
	(NOMINMAX): Define.
	

Index: gcc/gthr-win32.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gthr-win32.h,v
retrieving revision 1.20
diff -c -3 -p -r1.20 gthr-win32.h
*** gcc/gthr-win32.h	16 Dec 2002 18:19:37 -0000	1.20
--- gcc/gthr-win32.h	20 May 2003 07:38:24 -0000
*************** __gthread_active_p (void)
*** 365,371 ****
  #endif
  }
  
! #ifdef __GTHREAD_HIDE_WIN32API
  
  /* The implementations are in config/i386/gthr-win32.c in libgcc.a.
     Only stubs are exposed to avoid polluting the C++ namespace with
--- 365,371 ----
  #endif
  }
  
! #if __GTHREAD_HIDE_WIN32API
  
  /* The implementations are in config/i386/gthr-win32.c in libgcc.a.
     Only stubs are exposed to avoid polluting the C++ namespace with
Index: libstdc++-v3/config/os/mingw32/os_defines.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/os/mingw32/os_defines.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 os_defines.h
*** libstdc++-v3/config/os/mingw32/os_defines.h	24 Jun 2002 05:49:48 -0000	1.1
--- libstdc++-v3/config/os/mingw32/os_defines.h	20 May 2003 07:38:24 -0000
***************
*** 34,37 ****
--- 34,48 ----
  // System-specific #define, typedefs, corrections, etc, go here.  This
  // file will come before all others.
  
+ //  Define as 0, if you want, to enable inlining of gthread functions.
+ //  By default, don't pollute libstdc++ with win32api names.
+ #if !defined (__GTHREAD_HIDE_WIN32API)
+ # define __GTHREAD_HIDE_WIN32API 1
+ #endif
+ 
+ // Don't let win32api windef.h define min and max as macros
+ // if included after stl_algobase.h. 
+ #undef NOMINMAX
+ #define NOMINMAX 1
+ 
  #endif

http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]