problem with inline keyword
-
I have a function in CDocument file which I declared inline. When I call it from CView class, the linker reports LNK2001 error. If it's not inline then it works fine. Does anyone know what might be the problem?
dart13 wrote: Does anyone know what might be the problem? Are you declaring a function inline that you have overridden from an MFC class CDocument? Just a wild guess. Does the link error give any other info? Happy Programming and God Bless! Internet::WWW::CodeProject::bneacetp
-
dart13 wrote: Does anyone know what might be the problem? Are you declaring a function inline that you have overridden from an MFC class CDocument? Just a wild guess. Does the link error give any other info? Happy Programming and God Bless! Internet::WWW::CodeProject::bneacetp
The function is a member function of derived CDocument class, and I use it to access protected member variable which I created. If it is used within CMyDoc then it's ok, but when I call it from CMyView then the linker reports that error. Here is a full text of the error msg:
MyVew.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CMyDoc::IsButtonPressed(void)const " (?IsButtonPressed@CMyDoc@@QBE_NXZ)
-
I have a function in CDocument file which I declared inline. When I call it from CView class, the linker reports LNK2001 error. If it's not inline then it works fine. Does anyone know what might be the problem?
Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!
-
Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!
-
isn't the
inline
keyword made for declaring a function inline, wherever the code is written ?
TOXCCT >>> GEII power
no it's not. the compiler has to know to sources to "convert" it to code that fits in the calling function! Don't try it, just do it! ;-)
-
Is the code in the header file? The code for an inline function must be in a header file, because the code needs to be visible to every CPP file that calls the function. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot stop me with paramecium alone!