I am trying to make a general function for displaying error messages with the possibility of a program exit after a message appears.
I want the function to display the source file and the line where the error occurred.
argument list:
1.char *desc
2.char *file_name
3.u_int line
4.bool bexit=false
5.int code=0
Due to (4) and (5), I need to use the default arguments in the function definition, since I do not want them to be indicated if the program should not exit.
Due to (2) and (3), I need to use a macro that redirects to an unprocessed function, such as:
#define Error(desc, ???) _Error(desc,__FILE,__LINE__, ???)
The problem is that I do not see how these two elements should work together.
An example of what it should look like:
if(!RegisterClassEx(&wndcls))
Error("Failed to register class",true,1);
if(!p)
Error("Invalid pointer");
source
share