I was happily coding a custom class for Outpost 2 and I wanted a couple of the class member functions to be passable to Outpost 2 triggers. The problem is I'm using #include <vector>, so when I add the Export TYPEDEF to a member function, I get the following error: linkage specification is not allowed.
I googled the problem and found what appears to be a nice writeup by a gentleman named Michael Burr:
http://stackoverflow.com/questions/20139642/c2732-linkage-specification-errorFollowing his instructions, I enclosed the header file like this:
#if __cplusplus
extern "C" {
#endif
#include "Outpost2DLL\Outpost2DLL.h"
#include <cmath>
#include <vector>
class DisasterHelper
{
public:
Export void DisasterHelper::CreateRandomDisaster();
... MORE BAD CODE BY VAGABOND...
};
#if __cplusplus
}
#endif
ERRORSThen when compiling the source code, I get multiple of the following two errors:
- For Vector and associated headers: this declaration may not have extern 'C' linkage
- For cmath: 'abs': second C linkage of overloaded function not allowed
RESULTS/QUESTIONS1. Does this mean if I want to include C++ only classes in a custom Outpost 2 class, the class cannot contain the TYPEDEF Export?
2. The issue with cmath might be caused by an issue with my project settings, not sure. I'm getting the following caution when building a working copy of the scenario: LNK4098 defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library, which I have not really investigated yet.
I could fall back to c style arrays and just manage the array sizes manually. I would rather not though (call me lazy if you want), so just looking for feedback if the only options for a custom class are either to not use VECTOR or to not use Export.