Is it possible to prevent function parameter evaluation?
As I don’t want to evaluate the function parameter in some situation.
E.g.
To log a debug message,
void log(int severity, ...);
I want to log a message
log(DEBUG, "%s", getErrorMsg().c_str());
If the severity is DEBUG, the log function is just to return in release binary.
So, it is not necessary to evaluate getErrorMsg();
Any parameter you pass to a function will always be evaluated just before entry to the function.
You probably want to pass something like a pointer, so the pointer itself is what’s evaluated, and you only invoke a function via that pointer when/if necessary.