Is it possible to replace this preprocessor macro:
#define AL_CALL(a) do { a; \
ALenum e = alGetError(); \
if(e != AL_NO_ERROR) \
UtilitySoundNode::printALError(e,__FILE__, __LINE__); \
} while(0)
with a C++ template? If it is possible, will make any sense to do it (pros/cons - overhead/debugging)?
Note: Basically I am wondering if there is an elegant way to handle this kind of error handling in C++.
EDIT: Of course I made a mistake a is a function call. As one may guess it is a function call with parameters of a OpenAL function.
AL_CALL(someAlFunction(param1, param2))
NOTE: Somebody decided to edit the macro and make it nicer but I'd prefer to keep the original one too. So here it is:
#define AL_CALL(a) {a; ALenum e = alGetError();if(e != AL_NO_ERROR)PUtilitySoundNode::printALError(e,__FILE__, __LINE__);}
abe?abe that would make the statementa;make any sense? It is hard t answer this question without knowing that. Perhaps you meana();and it is a function pointer? If that is the case then a simple inline-functon is all that is needed, unless you need functons with different signatures.UtilitySoundNode::printALError!)