Jump to content
Sign in to follow this  
russdirks

Using .cpp files for a module

Recommended Posts

Hi,I'm trying to convert my FSConnect module from C to C++ so I can take advantage of the object oriented features of the language, but when I change the file extension to cpp, I get compile errors: error C2086: 'Linkage' : redefinition error C2086: 'ImportTable' : redefinitionIn a way, it makes sense, because those structures are declared twice. Makes me wonder how it worked in straight C.So I combined the declarations like this:__declspec(dllexport) GAUGES Linkage = { 0x0000520F, module_init, module_deinit, 0, 0, 0x0900, 0, 0 }; I did something similar for ImportTable.This compiles, but FS crashes on startup.Anybody tried this and got it to work?Thanks,Russ Dirks

Share this post


Link to post
Share on other sites
Guest bartels

Try something like:#ifndef EXTERN_C#ifdef __cplusplus #define EXTERN_C extern "C"#else #define EXTERN_C extern#endif#endif....EXTERN_C DECLSPEC_EXPORT GAUGESIMPORT ImportTable;EXTERN_C DECLSPEC_EXPORT GAUGESLINKAGE Linkage;Your code might look different, the point is to introduce an 'extern "C" ' declaration for C++ and 'extern' for C.Arne Bartels

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...