I am not familiar with ACE, but it appears that you are looking for the comma-deletion extension:
#define ERROR(FMT, ...) ACE_DEBUG((LM_ERROR, ACE_TEXT(FMT), ##__VA_ARGS__))
As described in the 'Variadic Macros' section of the GNU CPP manual, putting ##
in between a comma and __VA_ARGS__
has the special effect of removing the comma if and only if the macro was invoked with zero variable arguments. Thus,
ERROR("This is an example error");
ERROR("This is an example error %s", string);
will respectively expand to
ACE_DEBUG((LM_ERROR, ACE_TEXT("This is an example error")));
ACE_DEBUG((LM_ERROR, ACE_TEXT("This is an example error %s"), string));
which is probably what you want (again, I don't know ACE). Spacing in and around the three-token sequence , ## __VA_ARGS__
does not matter unless you care about portability to very old GCC, as in pre-EGCS.
This feature is a GNU extension, also supported by clang and anything that uses the EDG front end with its GNU compatibility mode enabled. Crucially, it is not supported by Microsoft's compilers as far as I know.
(Since it's almost Christmas, I should also mention that putting spaces on the inside of your parentheses makes the baby Jesus cry.)