Route inclusion of all Windows headers through a new header, windows_inc.h.

This allows us to make certain guarantees about limits on the extent of namespace pollution these headers introduce.

git-svn-id: https://svn.eduke32.com/eduke32@6065 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-02-19 22:15:44 +00:00
parent 79279780a5
commit d4ee6d00c8
36 changed files with 222 additions and 170 deletions

View file

@ -22,13 +22,10 @@
* DirectSound output driver for MultiVoc
*/
#define WIN32_LEAN_AND_MEAN
#define DIRECTSOUND_VERSION 0x0800
#define CINTERFACE
#define NEED_MMSYSTEM_H
#define NEED_DSOUND_H
#include "windows_inc.h"
#include <windows.h>
#include <mmsystem.h>
#include "dx/dsound.h"
#include <stdlib.h>
#include <stdio.h>

View file

@ -4,7 +4,6 @@
#define cache1d_h_
#include "compat.h"
#include "mutex.h"
#ifdef __cplusplus
extern "C" {

View file

@ -28,6 +28,7 @@
# define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
#endif
// XXX: only to avoid warning C4005: macro redefinition in winnt.h
#if !defined(_MSC_VER) || _MSC_FULL_VER < 180031101
#ifdef UNREFERENCED_PARAMETER
#undef UNREFERENCED_PARAMETER
@ -87,9 +88,9 @@
# include <malloc.h>
#endif
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
// XXX: see UNREFERENCED_PARAMETER
#if defined _MSC_VER && _MSC_FULL_VER >= 180031101
# include "windows_inc.h"
#endif
#ifdef __APPLE__

View file

@ -11,9 +11,9 @@
# define USE_GLEXT
#endif
// include this before glext does
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
# include "windows_inc.h"
#endif
// Tell gl.h to not include glext.h, we'll include our own copy in a minute

View file

@ -4,8 +4,7 @@
/* Mutual exclusion mechanism wrappers for the different platforms */
#ifdef RENDERTYPEWIN
# include <windows.h>
# include <process.h>
# include "windows_inc.h"
#else
# define SDL_MAIN_HANDLED
# include "sdl_inc.h"

View file

@ -1,6 +1,11 @@
#ifndef SDL_INC_H_
#define SDL_INC_H_
// include this before SDL does
#ifdef _WIN32
# include "windows_inc.h"
#endif
// Workaround for i686-MinGW-w64.
#if defined __MINGW64_VERSION_MAJOR && !defined __MINGW64__
# define __MINGW64_VERSION_MAJOR_BACKUP __MINGW64_VERSION_MAJOR

View file

@ -0,0 +1,122 @@
// Wrapper for all Windows headers.
// No include guard for this file.
#ifndef _WIN32_IE
# define _WIN32_IE 0x0501
#endif
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
#endif
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#ifdef NEED_WINSOCK2_H
# include <winsock2.h>
# undef NEED_WINSOCK2_H
#endif
#include <windows.h>
#ifdef NEED_WINDOWSX_H
# include <windowsx.h>
# undef NEED_WINDOWSX_H
#endif
#ifdef NEED_PROCESS_H
# include <process.h>
# undef NEED_PROCESS_H
#endif
#ifdef NEED_SHELLAPI_H
# include <shellapi.h>
# undef NEED_SHELLAPI_H
#endif
#ifdef NEED_WS2TCPIP_H
# include <ws2tcpip.h>
# undef NEED_WS2TCPIP_H
#endif
#ifdef NEED_COMMCTRL_H
# include <commctrl.h>
# undef NEED_COMMCTRL_H
#endif
#ifdef NEED_MMSYSTEM_H
# include <mmsystem.h>
# undef NEED_MMSYSTEM_H
#endif
#ifdef NEED_DDRAW_H
# define DIRECTDRAW_VERSION 0x0600
# ifndef CINTERFACE
# define CINTERFACE
# endif
# include "dx/ddraw.h"
# undef NEED_DDRAW_H
#endif
#ifdef NEED_DINPUT_H
# define INITGUID
# define DIRECTINPUT_VERSION 0x0700
# ifndef CINTERFACE
# define CINTERFACE
# endif
# include "dx/dinput.h"
# undef NEED_DINPUT_H
# if defined (_MSC_VER) || !defined(__cplusplus)
# define bDIPROP_BUFFERSIZE MAKEDIPROP(1)
# define bDIPROP_DEADZONE MAKEDIPROP(5)
# define bDIPROP_SATURATION MAKEDIPROP(6)
# else
# define bMAKEDIPROP(prop) ((REFGUID)(prop))
# define bDIPROP_BUFFERSIZE bMAKEDIPROP(1)
# define bDIPROP_DEADZONE bMAKEDIPROP(5)
# define bDIPROP_SATURATION bMAKEDIPROP(6)
# endif
# if defined (_MSC_VER) && defined(__cplusplus)
# define bREFGUID (REFGUID)
# define bREFIID (REFIID)
# else
# define bREFGUID &
# define bREFIID &
# endif
# ifndef DIK_PAUSE
# define DIK_PAUSE 0xC5
# endif
#endif
#ifdef NEED_DSOUND_H
# define DIRECTSOUND_VERSION 0x0800
# ifndef CINTERFACE
# define CINTERFACE
# endif
# include "dx/dsound.h"
# undef NEED_DSOUND_H
#endif
#ifdef NEED_CRTDBG_H
# include <crtdbg.h>
# undef NEED_CRTDBG_H
#endif
#ifdef NEED_DBGHELP_H
# if defined _MSC_VER && _MSC_VER < 1300
# define DECLSPEC_DEPRECATED
// VC6: change this path to your Platform SDK headers.
// must be XP version of file
// # include "M:\\dev7\\vs\\devtools\\common\\win32sdk\\include\\dbghelp.h"
# error "VC6 needs an updated dbghelp.h; see source"
# else
// VC7: ships with updated headers
# include <dbghelp.h>
# endif
# undef NEED_DBGHELP_H
#endif

View file

@ -4,8 +4,7 @@
#ifndef build_interface_layer_
#define build_interface_layer_ WIN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "windows_inc.h"
extern uint32_t maxrefreshfreq;

View file

@ -153,10 +153,7 @@ void readjoybstatus(int32_t *b)
*b = joyb;
}
#if defined _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#elif defined __linux || defined EDUKE32_BSD || defined __APPLE__
#if defined __linux || defined EDUKE32_BSD || defined __APPLE__
# include <sys/mman.h>
#endif

View file

@ -30,7 +30,8 @@
#include "compat.h"
#ifdef _WIN32
// for FILENAME_CASE_CHECK
# include <shellapi.h>
# define NEED_SHELLAPI_H
# include "windows_inc.h"
#endif
#include "cache1d.h"
#include "pragmas.h"

View file

@ -29,10 +29,6 @@
# endif
# include "hightile.h"
# include "polymost.h"
# ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# endif
#endif
#include <math.h> // pow

View file

@ -63,11 +63,6 @@ static __inline int32_t _lrotl(int32_t i, int sh) { return (i >> (-sh)) | (i <<
#endif
#endif
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif

View file

@ -1,4 +1,10 @@
#include "compat.h"
#ifdef _WIN32
# define NEED_PROCESS_H
# include "windows_inc.h"
#endif
#include "mutex.h"
int32_t mutex_init(mutex_t *mutex)

View file

@ -1,7 +1,7 @@
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0501
#include "windows_inc.h"
#include <malloc.h>
#include <windows.h>
#include "rawinput.h"
#include "winlayer.h"
#include "scancodes.h"

View file

@ -27,8 +27,6 @@
#endif
#if defined _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include "winbits.h"
#endif
#if defined __APPLE__

View file

@ -3,6 +3,11 @@
#endif
#include "compat.h"
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "renderlayer.h"
#ifdef STARTUP_SETUP_WINDOW
@ -11,15 +16,6 @@
#include "editor.h"
#include "winlayer.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0300
#endif
#include <commctrl.h>
#include <stdio.h>
#include "startwin.editor.h"
#define TAB_CONFIG 0

View file

@ -1,17 +1,18 @@
// Windows DIB/DirectDraw interface layer for the Build Engine
// Originally by Jonathon Fowler (jf@jonof.id.au)
#define DIRECTINPUT_VERSION 0x0700
#define DIRECTDRAW_VERSION 0x0600
#define _WIN32_WINNT 0x0501
#define WIN32_LEAN_AND_MEAN
#define CINTERFACE
#include <windows.h>
#include <math.h>
#include <malloc.h>
#include "build.h"
#define NEED_DINPUT_H
#define NEED_DDRAW_H
#ifdef _MSC_VER
# define NEED_CRTDBG_H
#endif
#include "windows_inc.h"
#include "winlayer.h"
#include "rawinput.h"
#include "mutex.h"
@ -19,38 +20,6 @@
#include "winbits.h"
#include "engine_priv.h"
#include "dx/ddraw.h"
#include "dx/dinput.h"
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
// bug in the dx headers
#if defined (_MSC_VER) || !defined(__cplusplus)
#define bDIPROP_BUFFERSIZE MAKEDIPROP(1)
#define bDIPROP_DEADZONE MAKEDIPROP(5)
#define bDIPROP_SATURATION MAKEDIPROP(6)
#else
#define bMAKEDIPROP(prop) ((REFGUID)(prop))
#define bDIPROP_BUFFERSIZE bMAKEDIPROP(1)
#define bDIPROP_DEADZONE bMAKEDIPROP(5)
#define bDIPROP_SATURATION bMAKEDIPROP(6)
#endif
// wtf, Microsoft?
#if defined (_MSC_VER) && defined(__cplusplus)
# define bREFGUID (REFGUID)
# define bREFIID (REFIID)
#else
# define bREFGUID &
# define bREFIID &
#endif
#ifndef DIK_PAUSE
# define DIK_PAUSE 0xC5
#endif
#include "dxdidf.h" // comment this out if c_dfDI* is being reported as multiply defined
#define __STDC_FORMAT_MACROS

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.editor.h"
RSRC_ICON ICON "build_icon.ico"

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.game.h"
RSRC_ICON ICON "game_icon.ico"

View file

@ -64,12 +64,6 @@ extern const char *s_buildRev;
extern const char *s_buildTimestamp;
extern const char *s_buildInfo;
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#endif
#include <signal.h>
// Workaround for namespace pollution in <sys/stat.h> introduced in MinGW 4.8.

View file

@ -30,12 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "osd.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
#endif
#define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw)
#define NUMALTKEYWORDS (int32_t)ARRAY_SIZE(altkeyw)

View file

@ -1,5 +1,12 @@
#include <cstdio>
#include "mdump.h"
#include <assert.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <tchar.h>
LPCSTR MiniDumper::m_szAppName;

View file

@ -1,15 +1,7 @@
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <assert.h>
#include <cstring>
#if _MSC_VER < 1300
#define DECLSPEC_DEPRECATED
// VC6: change this path to your Platform SDK headers
#include "M:\\dev7\\vs\\devtools\\common\\win32sdk\\include\\dbghelp.h" // must be XP version of file
#else
// VC7: ships with updated headers
#include "dbghelp.h"
#endif
#define NEED_DBGHELP_H
#define NEED_MMSYSTEM_H
#include "windows_inc.h"
// based on dbghelp.h
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,

View file

@ -41,8 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "compat.h"
#include "pragmas.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "windows_inc.h"
extern int32_t MUSIC_SoundDevice;

View file

@ -36,9 +36,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "compat.h"
#include "pragmas.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#define NEED_MMSYSTEM_H
#include "windows_inc.h"
static HMIDISTRM hmido = (HMIDISTRM)-1;
static MIDIOUTCAPS midicaps;

View file

@ -23,6 +23,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef netplay_h_
#define netplay_h_
#ifdef _WIN32
// include this before enet does
# define NEED_WINSOCK2_H
# include "windows_inc.h"
#endif
#include "enet/enet.h"
// net packet specification/compatibility version

View file

@ -25,6 +25,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
#include "compat.h"
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "renderlayer.h"
#ifdef STARTUP_SETUP_WINDOW
@ -34,15 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "grpscan.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0300
#endif
#include <commctrl.h>
#include <stdio.h>
#include "startwin.game.h"
// for ud

View file

@ -22,15 +22,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include "compat.h"
#include <windows.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <shellapi.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define NEED_SHELLAPI_H
#define NEED_WINSOCK2_H
#define NEED_WS2TCPIP_H
#include "windows_inc.h"
#include "renderlayer.h"

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.editor.h"
RSRC_ICON ICON "build_icon.ico"

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.game.h"
RSRC_ICON ICON "game_icon.ico"

View file

@ -4,16 +4,12 @@
#include "compat.h"
#include "build.h"
#include "winlayer.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0600
#endif
#include <commctrl.h>
#include <stdio.h>
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "winlayer.h"
#include "startwin.game.h"

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.editor.h"
RSRC_ICON ICON "game_icon.ico"

View file

@ -1,5 +1,5 @@
#include <windows.h>
#include <commctrl.h>
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "startwin.game.h"
RSRC_ICON ICON "game_icon.ico"

View file

@ -3,6 +3,11 @@
#endif
#include "build.h"
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "renderlayer.h"
#include "common.h"
@ -13,15 +18,6 @@
#include "grpscan.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#ifndef _WIN32_IE
#define _WIN32_IE 0x0300
#endif
#include <commctrl.h>
#include <stdio.h>
#include "startwin.game.h"
#define TAB_CONFIG 0

View file

@ -1,10 +1,9 @@
#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "dx/ddraw.h"
#include "compat.h"
#define NEED_DDRAW_H
#include "windows_inc.h"
#define DEFAULT_OUTPUT_FILE "enumdisplay.txt"
HMODULE hDDrawDLL = NULL;

View file

@ -1,14 +1,11 @@
// compile with:
// gcc -o getdxdidf.exe src\getdxdidf.c -Ic:\mingw32\dx6\include -Lc:\mingw32\dx6\lib -ldxguid -ldinput -mwindows
#define WIN32_LEAN_AND_MEAN
#define INITGUID
#define DIRECTINPUT_VERSION 0x0700
#include <windows.h>
#include "dx/dinput.h"
#include <stdio.h>
#include "compat.h"
#define NEED_DINPUT_H
#include "windows_inc.h"
char const * WhatGUID(const GUID *guid)
{
if (guid == &GUID_XAxis) return "&GUID_XAxis";