问题
I've got a static method, MyClass::myMethod()
on another DLL, MyDll.dll
. In my code, I call this method, and it compiles and runs fine.
But when I try MyClass::myMethod()
in the immediate window (or the watch window), I always get:
MyClass::myMethod()
CXX0052: Error: member function not present
Why is that?
Update: I've found out that when I use the context operator it works:
{,,MyDLL}MyClass::myMethod()
I'm not really sure why it's needed, though, so I'm going to wait a bit to see if someone has a nice explanation.
Update 2: I was asked to give more information. Unfortunately, what I described is almost all I have. This is in third-party code. The method, which resides on a different DLL, is declared like this:
class MyClass
{
public:
// ...
_declspec(dllimport) static const char *getDirectory(void);
}
and it is invoked like this:
MyClass::getDirectory ()
I haven't got the source. It was compiled on Debug mode under VC++9.
回答1:
Well, I'm not sure why, but the debugger isn't smart enough to know that class is in another DLL, so you have to explictly tell it by using the context operator:
{,,MyDLL}MyClass::myMethod()
回答2:
That's probably because your static function is defined inline.
My test with this class:
class myclass
{
public:
static int inlinetest()
{
return 0;
}
static int test();
};
int myclass::test()
{
return 0;
}
gives me this output in my immediate window:
myclass::inlinetest()
CXX0052: Error: member function not present
myclass::test()
0
来源:https://stackoverflow.com/questions/1051611/why-do-i-get-a-member-function-not-present-error-when-evaluating-expressions-o