In this program, we will use __FUNCTION__ macro to print the function name, also we will print all function names defined in the source code.
__FUNCTION__ Macro:
This macro is used to return the current function name. It is useful for debugging i.e., to generate the logs.
Program:
The source code to print the function names defined in the source code is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
// C program to print the function names
// defined in source code
#include <stdio.h>
void func1()
{
printf("%s\n", __FUNCTION__);
}
void func2()
{
printf("%s\n", __FUNCTION__);
}
void func3()
{
printf("%s\n", __FUNCTION__);
}
int main()
{
printf("Function are: \n");
func1();
func2();
func3();
printf("%s\n", __FUNCTION__);
return 0;
}
Output:
Function are:
func1
func2
func3
main
Explanation:
In the main() function, we called func1(), func2(), func3() function and print the function names using __FUNCTION__ macro on the console screen.
In this program, we will use __FUNCTION__ macro to print the function name, also we will print all function names defined in the source code.
__FUNCTION__ Macro:
This macro is used to return the current function name. It is useful for debugging i.e., to generate the logs.
Program:
The source code to print the function names defined in the source code is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.
Output:
Explanation:
In the main() function, we called func1(), func2(), func3() function and print the function names using __FUNCTION__ macro on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer