mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-29 18:11:38 +00:00
Fixed ISO C99 compatibility
SDL now builds with gcc 7.2 with the following command line options: -Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
This commit is contained in:
@@ -1086,7 +1086,9 @@ IsWin10FCUorNewer(void)
|
||||
HMODULE handle = GetModuleHandleW(L"ntdll.dll");
|
||||
if (handle) {
|
||||
typedef LONG(WINAPI* RtlGetVersionPtr)(struct SDL_WIN_OSVERSIONINFOW*);
|
||||
RtlGetVersionPtr getVersionPtr = (RtlGetVersionPtr)GetProcAddress(handle, "RtlGetVersion");
|
||||
RtlGetVersionPtr getVersionPtr;
|
||||
|
||||
*(void**)&getVersionPtr = GetProcAddress(handle, "RtlGetVersion");
|
||||
if (getVersionPtr != NULL) {
|
||||
struct SDL_WIN_OSVERSIONINFOW info;
|
||||
SDL_zero(info);
|
||||
|
||||
@@ -354,10 +354,10 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
||||
SDL_ClearError();
|
||||
return;
|
||||
}
|
||||
videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");
|
||||
videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC");
|
||||
videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC");
|
||||
videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC");
|
||||
*(void**)&videodata->ImmLockIMC = SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");
|
||||
*(void**)&videodata->ImmUnlockIMC = SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC");
|
||||
*(void**)&videodata->ImmLockIMCC = SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC");
|
||||
*(void**)&videodata->ImmUnlockIMCC = SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC");
|
||||
|
||||
IME_SetWindow(videodata, hwnd);
|
||||
videodata->ime_himc = ImmGetContext(hwnd);
|
||||
@@ -654,9 +654,9 @@ IME_SetupAPI(SDL_VideoData *videodata)
|
||||
if (!hime)
|
||||
return;
|
||||
|
||||
videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT))
|
||||
*(void**)&videodata->GetReadingString =
|
||||
SDL_LoadFunction(hime, "GetReadingString");
|
||||
videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
|
||||
*(void**)&videodata->ShowReadingWindow =
|
||||
SDL_LoadFunction(hime, "ShowReadingWindow");
|
||||
|
||||
if (videodata->ShowReadingWindow) {
|
||||
|
||||
@@ -119,15 +119,15 @@ WIN_GL_LoadLibrary(_THIS, const char *path)
|
||||
|
||||
/* Load function pointers */
|
||||
handle = _this->gl_config.dll_handle;
|
||||
_this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
|
||||
*(void**)&_this->gl_data->wglGetProcAddress =
|
||||
SDL_LoadFunction(handle, "wglGetProcAddress");
|
||||
_this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
|
||||
*(void**)&_this->gl_data->wglCreateContext =
|
||||
SDL_LoadFunction(handle, "wglCreateContext");
|
||||
_this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
|
||||
*(void**)&_this->gl_data->wglDeleteContext =
|
||||
SDL_LoadFunction(handle, "wglDeleteContext");
|
||||
_this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
|
||||
*(void**)&_this->gl_data->wglMakeCurrent =
|
||||
SDL_LoadFunction(handle, "wglMakeCurrent");
|
||||
_this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
|
||||
*(void**)&_this->gl_data->wglShareLists =
|
||||
SDL_LoadFunction(handle, "wglShareLists");
|
||||
|
||||
if (!_this->gl_data->wglGetProcAddress ||
|
||||
@@ -409,7 +409,7 @@ WIN_GL_InitExtensions(_THIS)
|
||||
}
|
||||
_this->gl_data->wglMakeCurrent(hdc, hglrc);
|
||||
|
||||
wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
|
||||
*(void**)&wglGetExtensionsStringARB =
|
||||
_this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
|
||||
if (wglGetExtensionsStringARB) {
|
||||
extensions = wglGetExtensionsStringARB(hdc);
|
||||
@@ -420,13 +420,9 @@ WIN_GL_InitExtensions(_THIS)
|
||||
/* Check for WGL_ARB_pixel_format */
|
||||
_this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
|
||||
if (HasExtension("WGL_ARB_pixel_format", extensions)) {
|
||||
_this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
|
||||
(HDC, const int *,
|
||||
const FLOAT *, UINT,
|
||||
int *, UINT *))
|
||||
*(void**)&_this->gl_data->wglChoosePixelFormatARB =
|
||||
WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
|
||||
_this->gl_data->wglGetPixelFormatAttribivARB =
|
||||
(BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
|
||||
*(void**)&_this->gl_data->wglGetPixelFormatAttribivARB =
|
||||
WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
|
||||
|
||||
if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
|
||||
@@ -438,9 +434,9 @@ WIN_GL_InitExtensions(_THIS)
|
||||
/* Check for WGL_EXT_swap_control */
|
||||
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
|
||||
if (HasExtension("WGL_EXT_swap_control", extensions)) {
|
||||
_this->gl_data->wglSwapIntervalEXT =
|
||||
*(void**)&_this->gl_data->wglSwapIntervalEXT =
|
||||
WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
|
||||
_this->gl_data->wglGetSwapIntervalEXT =
|
||||
*(void**)&_this->gl_data->wglGetSwapIntervalEXT =
|
||||
WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
|
||||
if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
|
||||
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
|
||||
@@ -721,9 +717,8 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wglCreateContextAttribsARB =
|
||||
(PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
|
||||
wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
*(void**)&wglCreateContextAttribsARB =
|
||||
_this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
if (!wglCreateContextAttribsARB) {
|
||||
SDL_SetError("GL 3.x is not supported");
|
||||
context = temp_context;
|
||||
|
||||
@@ -113,16 +113,16 @@ WIN_CreateDevice(int devindex)
|
||||
|
||||
data->userDLL = SDL_LoadObject("USER32.DLL");
|
||||
if (data->userDLL) {
|
||||
data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
|
||||
data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
|
||||
data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG)) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
|
||||
*(void**)&data->CloseTouchInputHandle = SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
|
||||
*(void**)&data->GetTouchInputInfo = SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
|
||||
*(void**)&data->RegisterTouchWindow = SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
|
||||
} else {
|
||||
SDL_ClearError();
|
||||
}
|
||||
|
||||
data->shcoreDLL = SDL_LoadObject("SHCORE.DLL");
|
||||
if (data->shcoreDLL) {
|
||||
data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *)) SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor");
|
||||
*(void**)&data->GetDpiForMonitor = SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor");
|
||||
} else {
|
||||
SDL_ClearError();
|
||||
}
|
||||
@@ -256,7 +256,7 @@ D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
|
||||
typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
Direct3DCreate9Ex_t Direct3DCreate9ExFunc;
|
||||
|
||||
Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex");
|
||||
*(void**)&Direct3DCreate9ExFunc = SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex");
|
||||
if (Direct3DCreate9ExFunc) {
|
||||
IDirect3D9Ex *pDirect3D9ExInterface;
|
||||
HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface);
|
||||
@@ -271,7 +271,7 @@ D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
|
||||
}
|
||||
#endif /* USE_D3D9EX */
|
||||
|
||||
Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9");
|
||||
*(void**)&Direct3DCreate9Func = SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9");
|
||||
if (Direct3DCreate9Func) {
|
||||
*pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION);
|
||||
if (*pDirect3D9Interface) {
|
||||
@@ -338,9 +338,7 @@ DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
|
||||
if (*pDXGIDLL) {
|
||||
HRESULT (WINAPI *CreateDXGI)(REFIID riid, void **ppFactory);
|
||||
|
||||
CreateDXGI =
|
||||
(HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL,
|
||||
"CreateDXGIFactory");
|
||||
*(void**)&CreateDXGI = SDL_LoadFunction(*pDXGIDLL, "CreateDXGIFactory");
|
||||
if (CreateDXGI) {
|
||||
GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}};
|
||||
if (!SUCCEEDED(CreateDXGI(&dxgiGUID, (void**)pDXGIFactory))) {
|
||||
|
||||
@@ -57,13 +57,13 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path)
|
||||
return -1;
|
||||
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
||||
SDL_arraysize(_this->vulkan_config.loader_path));
|
||||
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
|
||||
*(void**)vkGetInstanceProcAddr = SDL_LoadFunction(
|
||||
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
|
||||
if(!vkGetInstanceProcAddr)
|
||||
goto fail;
|
||||
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
|
||||
_this->vulkan_config.vkGetInstanceProcAddr = vkGetInstanceProcAddr;
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties =
|
||||
(void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
|
||||
(PFN_vkEnumerateInstanceExtensionProperties)_this->vulkan_config.vkGetInstanceProcAddr(
|
||||
VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
|
||||
if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
|
||||
goto fail;
|
||||
|
||||
Reference in New Issue
Block a user