When _ReturnAddress is used in a program compiled with /clr, the function containing the _ReturnAddress call will be compiled as a native function. When a function compiled as managed calls into the function containing _ReturnAddress, _ReturnAddress may not behave as expected.
Requirements
--------------------------------------------------------------------------------
Header file <intrin.h>
//貌似需要绝对匹配的
Example
--------------------------------------------------------------------------------
Copy // compiler_intrinsics__ReturnAddress.cpp
#include <stdio.h>
#include <intrin.h>
#pragma intrinsic(_ReturnAddress)
__declspec(noinline)
void noinline_func(void)
{
printf("Return address from %s: %p\n", __FUNCTION__, _ReturnAddress());
}
__forceinline
void inline_func(void)
{
printf("Return address from %s: %p\n", __FUNCTION__, _ReturnAddress());
}
int main(void)
{
noinline_func();
inline_func();
printf("Return address from %s: %p\n", __FUNCTION__, _ReturnAddress());
return 0;
}