개편이 다가온 시점에 질문글을 써서 죄송하네요.
#ifdef EXPORTRULE
#define MYDLL __declspec(dllexport)
#else
#define MYDLL __declspec(dllimport)
#endif
이 같은 매크로를 이용해서 DLL 클래스를 작성하였고
Code: Select all
//--- "myclass.h" ---
class MYDLL CMyClass
{
private:
CMyClass() {}
~CMyClass() {}
public:
static const int SEVEN = 7;
static const float PI;
};
//--- "myclass.cpp" ---
#include "myclass.h"
const float CMyClass::PI = 3.14f;
//--- "main.cpp" ---
#include "myclass.h"
int main()
{
printf("%d", CMyClass::SEVEN); // OK
printf("%f", CMyClass::PI); // LNK2001
}
static const int 같은 경우는 헤더에서 초기화 및 링크가 잘 되는데
static const float의 경우 LNK2001 에러가 발생합니다.
이런 경우 함수를 사용하거나 define 혹은 전역 변수를 쓸 수 밖에 없는지
고수님들의 의견을 듣고 싶습니다.
감사합니다.