Menu

suggestion

2002-09-11
2012-09-26
  • Nobody/Anonymous

    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.

     
    • Nobody/Anonymous

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.