Hello,
For a project I need to handle numbers that only have a predefined range of values [0, max) (not known at compile time) and after reaching the end, wrap to 0, i.e. max == 0, max + 1 == 1, etc.
The project is organized in a way that there is the main executable (a) that loads dynamically 2 dlls (b, c).
Since "c" handles most of the arithmetics, I defined the class in "c".
But the numbers are used all over the project (in a, b and c).
I implemented the modulus (= max) as a static protected member of the class to ensure the same modulus for all numbers (there is no use in adding/comparing/.. numbers based on separate moduli).
Right now I define the static member in c.cpp.
In Visual Studio I receive an error "error LNK2001: not resolved external symbol <my static member variable>".
This error is shown only in "a" and "b", not in "c" ("c" compiles without errors)
This looks to me as if it's not accessible in "a" and "b".
btw: I have not mentioned it in "c"s def file.
I include the Headerfile "c.h" in "a" and "b".
What can I do?
c.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
ifndef myPosType_h
#define myPosType_h
#include <cassert>
#include <limits>
#include "myLogger.h"
class MyPosBaseType
{
public:
typedef long long baseType;
static void setModulo(const baseType modulo)
{
modulo_ = modulo;
}
protected:
static baseType modulo_;
};
class MyPosDiffType : public MyPosBaseType
{
// operations such as adding, comparing, constructors etc.
// used for position differences
};
class MyPosType : public MyPosBaseType
{
// operations such as adding, comparing, constructors etc.
// used for positions
};
#endif
|
c.cpp:
1 2 3 4
|
#include "stdafx.h"
#include "myPosType.h"
MyPosBaseType::baseType MyPosBaseType::modulo_ (8192000);
|