C2086: 'int WINGDIAPI' : redefinition errors in Open Scene Graph?
Asked Answered
M

5

5

I've solved this problem (from here). Just putting it here, so that anyone else who encounters the error will find a cleaner question and answer than to have to go dig through the website where I got it from. I'll be answering this question soon myself.

The errors encountered are:

Error 13 error C2086: 'int APIENTRY' : redefinition C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GL\gl.h 1153  
Error 10 error C2086: 'int WINGDIAPI' : redefinition C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GL\gl.h 1153   
Error 3 error C2144: syntax error : 'void' should be preceded by ';' C:\Program Files\Microsoft Visual Studio 10\VC\include\GL\gl.h 1152 
Manama answered 12/4, 2012 at 3:32 Comment(0)
M
8

The solution is: [Obtained from this website]

You need to add WIN32 to the defines in your project. In Visual Studio, right-click on your project, go to C/C++, Preprocessor, and in the Preprocessor Definitions field add WIN32 for both debug and release configurations. While you're at it, also add _DEBUG for the debug configuration and NDEBUG for the release configuration...
For some reason the default VS projects have no preprocessor definitions, even though these, at least, should almost always be used...

Manama answered 12/4, 2012 at 3:32 Comment(0)
M
5

My solution already contained those Preprocessor definitions. MSDN suggest that you also add #include <windows.h>

Marrow answered 28/1, 2013 at 20:1 Comment(0)
L
3

I had a piece of code looking for _WIN32 as opposed to just WIN32.

For what it's worth, popular sound library uses this before including windows.h:

#if defined(_WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64)
#include <windows.h>
#endif
Luthuli answered 2/1, 2014 at 21:42 Comment(0)
C
1

I want to add CMake solution as well.

You should add /D "WIN32" to CMAKE_CXX_FLAGS which can be found in the advanced entries.

Crinite answered 6/11, 2013 at 10:2 Comment(0)
G
0

I recently ran into this with an empty project using Visual C++ 2019.

What worked for me was to define _WINDOWS as a preprocessor directive instead of WIN32.

Gospodin answered 5/11, 2019 at 6:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.