
I have been making an effort to write Windows independent code. In particular I avoid including windows.h in any of my headers (some implementation files include it). I have had a problem using Boost/pool as the mutex header includes windows.h (causing nameclashes with some of my existing code, which has always relied on the absence of windows.h). Possible inclusion of windows.h is documented in the section on mutex. My question is 'Is it really necessary or desirable ?'. Is there a Boost policy on the inclusion of OS specific headers which create a large number of declarations in the global namespace ? The section which uses windows.h is: #ifdef BOOST_WINDOWS class win32_mutex { private: ::CRITICAL_SECTION mtx; win32_mutex(const win32_mutex &); void operator=(const win32_mutex &); public: win32_mutex() { ::InitializeCriticalSection(&mtx); } ~win32_mutex() { ::DeleteCriticalSection(&mtx); } void lock() { ::EnterCriticalSection(&mtx); } void unlock() { ::LeaveCriticalSection(&mtx); } }; #endif // defined(BOOST_WINDOWS) I believe that the appropriate declarations of InitializeCriticalSection, DeleteCriticalSection, EnterCriticalSection, LeaveCriticalSection could be provided explicitly in this file and hence avoid including windows.h and the subsequent namespace 'pollution'. An alternative of using a Boost multithreading library is suggested in the documentation. This would be ideal, but my proposal would solve problem now, relatively effortlessly. PS. I did a quick edit and got it to work (at least on Vista). The change to the if-endif block is shown below. It could be done much better. # ifdef BOOST_WINDOWS //#include <windows.h> typedef char CRITICAL_SECTION[24]; //24 is sizeof(CRITICAL_SECTION) ! typedef CRITICAL_SECTION *LPCRITICAL_SECTION; #define WINAPI __stdcall extern void WINAPI InitializeCriticalSection( __out LPCRITICAL_SECTION lpCriticalSection ); extern void WINAPI DeleteCriticalSection( __inout LPCRITICAL_SECTION lpCriticalSection ); extern void WINAPI EnterCriticalSection( __inout LPCRITICAL_SECTION lpCriticalSection ); extern void WINAPI EnterCriticalSection( __inout LPCRITICAL_SECTION lpCriticalSection ); void WINAPI LeaveCriticalSection( __inout LPCRITICAL_SECTION lpCriticalSection ); # endif many regards, Paul