Im trying to make a generic function to display error messages, with the possibility that the program should exit after the message has been displayed.
I want the function to show the source file and line at which the error occurred.
argument list:
1.char *desc //description of the error
2.char *file_name //source file from which the function has been called
3.u_int line //line at which the function has been called
4.bool bexit=false //true if the program should exit after displaying the error
5.int code=0 //exit code
Because of (4) and (5) i need to use default arguments in the function definition, since i don't want them to be specified unless the program should exit.
Because of (2) and (3) i need to use a macro that redirects to the raw function, like this one:
#define Error(desc, ???) _Error(desc,__FILE,__LINE__, ???)
The problem is that i don't see how those 2 elements should work together.
Example of how it should look like:
if(!RegisterClassEx(&wndcls))
Error("Failed to register class",true,1); //displays the error and exits with exit code 1
if(!p)
Error("Invalid pointer"); //displays the error and continues