I use GLx (http://www.brainlex.com/3d.php) and have a funny problem - GLX itself is C, I usually program in C++ - would it be possible to call the compiler corresponding to the file-endings (i.e. gcc for .c, g++ for .cpp)? At the moment I have to edit the makefile the first time i compile or to copy the glx.o - otherwise the compiler fails with "ansi c++ forbids implicit conversion of void* ..." - not a big problem, and maybe it's no good practice to mix c and c++ in a project, but ....
greetings
J. F.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is that the linker get's into trouble when you mix c and c++, because the function calling is diffrent. You should compile you project as c++ and use the extern "c" keyword for function prototypes that are native c.
You can try adding the following to you code :
#ifdef __cplusplus
extern "C" {
#endif
// now include the C stuff
#include "theGLxheadersinnativeC.h"
#ifdef __cplusplus
}
#endif
If you use g++ then it will add the extern "C" and if you use just C then it will not do that. I think this might work, but i'm not sure whether the this between the optional brackets are handled correctly. You have to try it yourself
stephan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use GLx (http://www.brainlex.com/3d.php) and have a funny problem - GLX itself is C, I usually program in C++ - would it be possible to call the compiler corresponding to the file-endings (i.e. gcc for .c, g++ for .cpp)? At the moment I have to edit the makefile the first time i compile or to copy the glx.o - otherwise the compiler fails with "ansi c++ forbids implicit conversion of void* ..." - not a big problem, and maybe it's no good practice to mix c and c++ in a project, but ....
greetings
J. F.
The problem is that the linker get's into trouble when you mix c and c++, because the function calling is diffrent. You should compile you project as c++ and use the extern "c" keyword for function prototypes that are native c.
You can try adding the following to you code :
#ifdef __cplusplus
extern "C" {
#endif
// now include the C stuff
#include "theGLxheadersinnativeC.h"
#ifdef __cplusplus
}
#endif
If you use g++ then it will add the extern "C" and if you use just C then it will not do that. I think this might work, but i'm not sure whether the this between the optional brackets are handled correctly. You have to try it yourself
stephan