I'm making a profiler in a project, and I want to make it easy to integrate into my projects. I'm using penter and pexit with the /GH /Gh compiler flags so those functions are called every time a function is called or returned from. Right now, basically all I have to do in my projects is copy over the penter and pexit function anywhere in the global scope and that works, but I want to make a macro so it just basically inserts the function in. I defined the macro in my Profiler.h file and included that in my other project. the errors i'm getting are
error C2598: linkage specification must be at global scope
error C2601: '_pexit' : local function definitions are illegal
error C1075: end of file found before the left brace '{' at 'path/main.cpp' was matched
note that 'path/main.cpp' is a long path to my project (non-profiler project) and main is where i'm 'calling' the macros
here are my macros, I must be understanding these wrong. I figured it'd just insert the function where it was 'called'
#define PENTER \
extern "C" void __declspec(naked) _cdecl _penter(void) \
{ \
_asm push ebp; \
_asm mov ebp, esp; \
_asm pushad; \
Profiler::GetInstance().Enter(); \
_asm popad; \
_asm mov esp, ebp; \
_asm pop ebp; \
_asm ret; \
} \
#define PEXIT \
extern "C" void __declspec(naked) _cdecl _pexit(void) \
{ \
_asm push ebp; \
_asm mov ebp, esp; \
_asm pushad; \
Profiler::GetInstance().Exit(); \
_asm popad; \
_asm mov esp, ebp; \
_asm pop ebp; \
_asm ret; \
} \
Thanks for any help!