October 3, 200322 yr 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
October 3, 200322 yr 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
Create an account or sign in to comment