Question:
Is there a macro that returns the name of a function which calls the macro? If not, how can I define such a macro?
Answer:
Yes and no. The newly approved C99 standard defines the reserved variable __FUNCTION__ as the name of the current function. However, only few compilers support this feature. Two such compilers are GCC and Borland’s C++ Builder 5.0. The latter uses a different name, though: __FUNC__ but it has the same functionality. As an aside, these variables aren’t implemented as macros; they are variables. Macros are defined by the preprocessor, which knows very little about C++ constructs such as functions and blocks. Therefore, __FUNCTION__ can’t be a macro.
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























