SDL depends on file I dont have

When I debbuged my SDL & GL program, that is meant to have a window pop up(that is all i have done so far) there is an error.
Main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <SDL/SDL.h>
#include <GL/glew.h>
#include "MainGame.h"

int main(int argc, char** argv)
{
	MainGame mainGame;

	mainGame.RunGame();

	while (1){}
	return 0;
}

And my MainGame class: .h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once
#include <SDL/SDL.h>
class MainGame
{
public:
	MainGame();
	~MainGame();

	void RunGame();
	void InitSystems();
private:
	SDL_Window* _window;

	int _screenWidth, _screenHeight;
};
and .cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "MainGame.h"


MainGame::MainGame()
{
	_window = nullptr;
	_screenWidth = 1024;
	_screenHeight = 768;
}


MainGame::~MainGame()
{
}


void MainGame::RunGame()
{
	InitSystems();
}

void MainGame::InitSystems()
{
	//Initialize SDL
	SDL_Init(SDL_INIT_EVERYTHING);

	_window = SDL_CreateWindow(
		"Nick's Game",				//Window Title
		SDL_WINDOWPOS_CENTERED,     //Window PosX
		SDL_WINDOWPOS_CENTERED,		//Window PosY
		_screenWidth,				//Window Width
		_screenHeight,				//Window Height
		SDL_WINDOW_OPENGL);			//Window Flag	


}

The error occurs in SDL_platform which is in my include folder in deps for dependencies.
1
2
3
4
5
6
7
8
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
/* Try to find out if we're compiling for WinRT or non-WinRT */
/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */
#if (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_)	/* _MSC_VER==1700 for MSVC 2012 */
#include <winapifamily.h>                                      //BUG HERE <<<
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#undef __WINDOWS__
#define __WINDOWS__   1 
I just cut out the area around the problem.
Where is says #include <winapifamily.h> I did't have the winapifamily.h, it was easy enough to download it from the internet but once i did that and added it to my include folder, my program then required stddef.h which i didnt have, so i included it. But now I have repeated this process 6 times each time needing a new file. How do I fix this because clearly adding each one isnt going to get me anywhere. Im sorry about the explanation being long but its a wierd problem and its the only way to explain it.
I did some research and it turns out its a bug in SDL that should be fixed later on, none of the fixes I tried worked, I downloaded a fixed SDL_platform but that didn't work. Any help would be gratefully appreciated. This is my first time using SDL and I dont really know why this is happening, sorry for the long question.
yeah, it's a bug in the current SDL version, it will be fixed in the next version.

Replace your SDL_platform.h with this one:
https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h

Note: the first result on google solved the problem:
http://lmgtfy.com/?q=sdl+winapifamily.h
Last edited on
Yes I have tried the fixed SDL_platform.h none of the 2 that I tried work, they both attempt to include winapifamily.h which is the original problem, I have been to the Stack Overflow post and failed to get it to work. Removing lines from the code dosn't fix it.
maybe you downloaded the false version...

Do you use Visual Studio?
If not try installing the mingw-developer-package, there winapi is not included
https://www.libsdl.org/download-2.0.php
(direct download link: https://www.libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz)
Last edited on
I am using visual studio 2013
Topic archived. No new replies allowed.