Get the address of an instruction in C/C++

Viewed 6469

Any ways to get the address of an instruction? I have tried to used to labeled the instruction and get the address of the label but seems that it only works in GCC compiler with the && operator. (Refer to: this article) What if other compilers?

Any thoughts of this question?

4 Answers

The return address of a function is the location of the next instruction to be executed upon return from the current function. GCC exposes this through __builtin_return_address; while Visual C++ provides it via _ReturnAddress.

Related