Closed diath closed 8 months ago
This is not a raylib bug
This is because of the namespaces. Including standard library headers inside a namespace doesn't work in this case, because the type definitions in the header will be inside the namespace as well, and can't be accessed from global scope. You can fix this by first including cstdarg before raylib.h Example: https://github.com/raylib-extras/extras-cpp/blob/main/raylib_namespace.h
Everything also works totally fine if you remove the namespace, because then the types will be in the global namespace as expected.
I don't think there's a way for this to be fixed. Just include the header before, this define is totally unnecessary and a horrible idea.
Issue description
Raylib currently cannot be included by a C++ project that later includes
cstdio
(either directly, or indirectly by another library such asfmt
in my case). The culprit appears to be the include ofstdarg.h
inraylib.h
. Commenting out thestdarg.h
include inraylib.h
and the tracelog function makes it possible to compile programs using raylib that includecstdio
. Perhaps we could get a define like#define RAYLIB_NO_TRACELOG
that can be defined before includingraylib.h
that removes the tracelog functionality and allows for including it in C++ projects that usecstdio
.Code Example
The following code compiles fine:
The following code does not compile:
With a number of errors coming from the
cstdio
header: