# OBSApi and Windows headers



## hauzer (Apr 10, 2014)

OBSApi behaves wonky when including various Windows headers alongside it. Take the following examples:

*Compiles*

```
#include <OBSApi.h>
#include <Windows.h>

int main() { }
```

*Doesn't compile*

```
#include <Windows.h>
#include <OBSApi.h>

int main() { }
```

*Doesn't compile*

```
#include <sphelper.h>
#include <OBSApi.h>

int main() { }
```

*Doesn't compile*

```
#include <OBSApi.h>
#include <sphelper.h>

int main() { }
```

And so on. I'm not sure if the git version has this fixed (I don't have VS2013), but if it's not, it should be as soon as possible.


----------



## Jim (Apr 11, 2014)

Yes, you do have to include the headers in the correct order for OBS1.  It works fine on git.


----------



## hauzer (Apr 11, 2014)

Nope, just tried git. Upon further inspecting OBSApi.h, I think I've come up with a temporary solution:

```
#include <Windows.h>

#ifdef WINVER
#define WINVER_REAL WINVER
#undef WINVER
#endif
#ifdef _WIN32_WINNT
#define WIN32_WINNT_REAL _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#ifdef NTDDI_VERSION
#define NTDDI_VERSION_REAL NTDDI_VERSION
#undef NTDDI_VERSION
#endif
#ifndef _INC_COMMCTRL
#define _INC_COMMCTRL
#define INC_COMMCTRL_DO_UNDEF
#endif
#include <OBSApi.h>
#ifdef INC_COMMCTRL_DO_UNDEF
#undef _INC_COMMCTRL
#undef INC_COMMCTRL_DO_UNDEF
#endif
#ifdef NTDDI_VERSION_REAL
#undef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_VERSION_REAL
#undef NTDDI_VERSION_REAL
#endif
#ifdef WIN32_WINNT_REAL
#undef _WIN32_WINNT
#define _WIN32_WINNT WIN32_WINNT_REAL
#undef WIN32_WINNT_REAL
#endif
#ifdef WINVER_REAL
#undef WINVER
#define WINVER WINVER_REAL
#undef WINVER_REAL
#endif


int main()
{

}
```

This indeed compiles.


----------

