I am trying to figure out how to write a preprocessor macro which will "stringify" its argument only if an argument is present
For example:
STRINGIFY(foo) -> "foo"
STRINGIFY() ->
In my very basic example:
#define STRINGIFY(x) #x
Calling STRINGIFY() results in "" rather than nothing at all (which is what I want)
How can this be achieved?
EDIT
As An example of why I want this behavior, I am using the macro to generate an initializer for an array of strings as such
const char* STRINGS[] = {MAP_LIST(STRINGIFY, __VA_ARGS__)};
Where MAP_LIST comes from the following project: https://github.com/swansontec/map-macro
If my VA_ARGS lsit has items in it, you end up with, for example, the following:
const char* STRINGS[] = {"a", "b", "c"};
But if VA_ARGS is empty, I end up with:
const char* STRINGS[] = {""};
Because, when you "stringify" an empty argument, it gives you an empty string.