using externally defined function pointers
-
Dear Programmers, I am working on an MFC/Dialog based project. I defined a function pointer in a class's header file as a static like below; ... typedef BOOL (WINAPI *blTagHCWDOGEnable)(DWORD IN_dwSecTime); static blTagHCWDOGEnable blHCWDOGEnable; ... Then I initialised this function pointer from a dll with ordinary function (LoadLibrary(...) , GetProcAddress(...)) Everything is working OK in this class. I am able to use this function but when I try to use this function from another class I am encountering errors. As if something modifying content of function pointer and it is equaling to NULL. What may cause this? Thanks and best regards
-
Dear Programmers, I am working on an MFC/Dialog based project. I defined a function pointer in a class's header file as a static like below; ... typedef BOOL (WINAPI *blTagHCWDOGEnable)(DWORD IN_dwSecTime); static blTagHCWDOGEnable blHCWDOGEnable; ... Then I initialised this function pointer from a dll with ordinary function (LoadLibrary(...) , GetProcAddress(...)) Everything is working OK in this class. I am able to use this function but when I try to use this function from another class I am encountering errors. As if something modifying content of function pointer and it is equaling to NULL. What may cause this? Thanks and best regards
Erkan Ermis wrote: What may cause this? The
static
keyword. Each file that uses your header file will get its own copy of the variable, so if you set it from one file, other files won't see the change. Changestatic
toextern
and define the variable in one of the .cpp files without theextern
keyword. That should help it to work.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Erkan Ermis wrote: What may cause this? The
static
keyword. Each file that uses your header file will get its own copy of the variable, so if you set it from one file, other files won't see the change. Changestatic
toextern
and define the variable in one of the .cpp files without theextern
keyword. That should help it to work.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-