What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__ in C/C++?

C++Server Side ProgrammingProgramming

Here we will see what are the differences between __FUNCTION__, __func__ and the __PRETTY_FUNCTION__ in C++.

Basically the __FUNCTION__ and __func__ are same. Some old versions of C and C++ supports __func__. This macro is used to get the name of the current function. The _PRETTY_FUNCTION__ is used to return the detail about the function. Using this we can get which function is used, and in which class it is belonging, etc.


using namespace std;
class MyClass{
      void Class_Function(){
         cout << "The result of __PRETTY_FUNCTION__: " << __PRETTY_FUNCTION__ << endl;
void TestFunction(){
   cout << "Output of __func__ is: " << __func__ << endl;
main() {
   cout << "Output of __FUNCTION__ is: " << __FUNCTION__ << endl;
   MyClass myObj;


Output of __FUNCTION__ is: main
Output of __func__ is: TestFunction
The result of __PRETTY_FUNCTION__: void MyClass::Class_Function()
Updated on 30-Jul-2019 22:30:25