From: Earnie B. <ea...@us...> - 2003-11-05 13:07:00
|
Test case? Versions? ``gcc -v'' and ``as -v'' Earnie Stephan T. Lavavej wrote: > w32api has a habit of using C casts in macros. This causes a problem when > C++ programs are compiled with -Wold-style-cast, as gcc isn't yet smart > enough to figure out that the C cast is coming from something defined in a > system header. > > I have already filed a gcc PR about this, http://gcc.gnu.org/PR12258 , but > it doesn't look like it will be fixed any time soon. > > It would be nice if w32api had appropriate ifdefs so that when it is used > with C++ programs, C++ casts are used in macros. > > There are four macros which currently affect me: > winsock2.h: > #define INVALID_SOCKET (SOCKET)(~0) > #define INADDR_ANY (u_long)0 > > winbase.h: > #define INVALID_HANDLE_VALUE (HANDLE)(-1) > #define STD_OUTPUT_HANDLE (DWORD)(0xfffffff5) > > Looking through w32api reveals that there are many more. > > These four in particular should be, when compiled with C++: > > INVALID_SOCKET: > static_cast<SOCKET>(-1) instead of (SOCKET)(~0) > INADDR_ANY: > static_cast<u_long>(0) instead of (u_long)0 > INVALID_HANDLE_VALUE: > reinterpret_cast<HANDLE>(-1) instead of (HANDLE)(-1) > STD_OUTPUT_HANDLE: > static_cast<DWORD>(0xFFFFFFF5) instead of (DWORD)(0xfffffff5) > > I would, in fact, wager that all but INVALID_HANDLE_VALUE don't even need to > be cast. > > Stephan T. Lavavej > http://nuwen.net > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users > -- http://www.mingw.org Powered by SourceForge <http://sourceforge.net/projects/mingw> |