I can only speak for my own project, but making windows.h visible through
SDL_config_win32.h would cause my code to explode. Windows defines such
symbols as “true”, “false”, and “byte” which are not reserved words in
ANSI C, and thus my program should be free to use them so long as it is
not trying to also use Win32 code in the same modules. Because my program
is highly portable, this happens to be the case. Anywhere we do need
Win32-specific code, for example getting the process path and name, or
setting the process affinity mask so that SDL’s multicore-CPU audio
crashes go away, that code is isolated in modules that do not include the
conflicting definitions.
Bringing windows.h into every client module that uses SDL, whether it
is needed or not, is just major namespace pollution and should really
be thought about carefully. I’ve already had problems with this header
in the past (first conflicting with a macro to replace malloc, and then
again conflicting with the addition of a stdint.h/inttypes.h for Visual
C++). I’d hate to see it blow up on me yet again :(----------------------------------------
Date: Tue, 11 Aug 2009 17:01:29 -0700
From: ali_lowe at sky.com
To: sdl at lists.libsdl.org
Subject: [SDL] Cleanup #include Windows.h proposal
Hi guys,
I’ve been trying to integrate some code of mine into SDL and have discovered
that just by including SDL_opengl.h in SDL_sysvideo.h it brings up just
under 100 warnings and errors. I’ve decided that it appears to be the early
including of windows.h that is done in SDL_opengl.h and sure enough, moving
some of the defines over from sysvideo reduces the error count. However
these are still some errors that I can assume are from other windows
includes in other files where I’ve not copied over their defines to
SDL_opengl.h.
I would like to propose that we consolidate the setting up of windows
defines and the including of windows.h into SDL_config_win32.h, as almost
every sdl file includes SDL_config.h (and thus config_win32) as the very
first line of code. Ultimately windows.h is only going to get included once
so it’ll be a good idea for us to have control over when and be able to see
all the defines in one location. This will help clear clutter from files
that distract from the functional code and hopefully make future
modifications easier by lessening the volatility of including windows.h out
of order.
Does this proposal sound reasonable? If so I’ll look into making the
changes. I suspect that similar measures could be taken for x11 etc as well.
Many thanks.
View this message in context: http://www.nabble.com/Cleanup--include-Windows.h-proposal-tp24927834p24927834.html
Sent from the SDL mailing list archive at Nabble.com.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1