Dav1dde / glad

Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.
https://glad.dav1d.de/
Other
3.79k stars 448 forks source link

compile error #381

Closed amrezaee closed 2 years ago

amrezaee commented 2 years ago

Hi. glad on visual studio 2022 produces following error: "fatal error C1189 c++ compiler expected in yvals_core.h" I changed glad.c to glad.cpp and it fixed the problem. (my project is c++) I think the problem is that glad.c includes a header file which contains "yvals_core.h" and compiling that produces above error. glad config: opengl core profile 4.6 gles2 3.1 ARB and EXT and AMD extensions. generate loader checked. I use cmake.

amrezaee commented 2 years ago

probably this is related to https://github.com/microsoft/STL/pull/2148

Dav1dde commented 2 years ago

I assume this is the same issue as here: https://github.com/Dav1dde/glad/issues/371

I don't understand the problem, glad does not include any STL headers, the only include which maybe could be problematic is windows.h.

Dav1dde commented 2 years ago

I setup MSVC 2022 with an example project and it compiles without issues: image

Can you setup a minimal example I can just import?

amrezaee commented 2 years ago

I just included glad.h in a precompiled header and added that pch with target_precompile_headers function in cmake.

amrezaee commented 2 years ago

OK i think i found the problem. The problem is that precompiling glad.h with other headers which include STL headers causes that error. in glad.c there is an "#include<glad/glad.h>" which uses that pch with STL headers instead of glad.h file. and msvc generates error because STL headers included in glad.c which is a c source file.

amrezaee commented 2 years ago

To reproduce the error include glad.h and a random STL header in a pch and use that pch in your program.

amrezaee commented 2 years ago

OK I'll use glad2 which has header only option which is easier to precompile.

Dav1dde commented 2 years ago

I don't think there is anything I can do about that in glad.