Hello everybody.
I'm beginner in C programing and need some help with converting C++ header to C.
I have great game engine that was written in Visual C++, all functions use stdcall calling conv. Then i try building project, compiler outputs errors about defined functions.
Here dll, lib & header. (http://www.mediafire.com/?ads7z6qx1p1pf8u)
For start try this:
Use compiler options -Ze -Zx
// Delaration & call macros
#ifdef __cplusplus
#define X3DDECL extern "C" __declspec(dllexport)
#else
#define X3DDECL
#endif
#define X3DCALL _stdcall
#ifndef bool
#define bool BOOL
#endif
#ifndef true
#define true TRUE
#endif
#ifndef false
#define false FALSE
#endif
Quote from: timovjl on June 11, 2011, 12:01:01 AM
For start try this:
Use compiler options -Ze -Zx
// Delaration & call macros
#ifdef __cplusplus
#define X3DDECL extern "C" __declspec(dllexport)
#else
#define X3DDECL
#endif
#define X3DCALL _stdcall
#ifndef bool
#define bool BOOL
#endif
#ifndef true
#define true TRUE
#endif
#ifndef false
#define false FALSE
#endif
Thanks, it works. But I have a couple more questions. How i should declare a
NULL variable? Why when i'm using "
int main(int argc, char *argv[ ]) {...}" i have error -
POLINK: error: Unresolved external symbol '_WinMain@16'. POLINK: fatal error: 1 unresolved external(s); and if building project using "
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszCmdline, int nCmdShow)" all compiling without any problems?
QuoteWhy when i'm using "int main(int argc, char *argv[ ]) {...}" i have error - POLINK: error: Unresolved external symbol '_WinMain@16'. POLINK: fatal error: 1 unresolved external(s)
In that case change linkers Subsystem Type to Console
Linker option: -subsystem:console
There is indeed such a tool, Comeau's C++ compiler. . It will generate C code which you can't manually maintain, but that's no problem. You'll maintain the C++ code, and just convert to C on the fly.