- 1 year ago
Widen version of __FUNCTION__ in Linux
Comment
1 / 1
In Linux, the __FUNCTION__
macro expands to the current function name as a string literal, which has a fixed width and cannot be modified. If you need a wider version of the function name, you can use the __func__
predefined identifier, which provides a wider representation of the function name.
Here's an example to illustrate the usage:
cpp#include <iostream>
void foo()
{
std::cout << "Function name: " << __func__ << std::endl;
}
int main()
{
foo();
return 0;
}
In this example, __func__
is used to access the function name. Unlike __FUNCTION__
, __func__
is not a macro but a predefined identifier that represents the current function name as a wide string.
By using __func__
, you can get a wider representation of the function name in Linux.