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
Help AVSIM continue to serve you!
Please donate today!

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