I have
#define STRING "string"
I want to add L prefix to STRING macro later in my code (I can't do it in definition). How to do it?
I have
#define STRING "string"
I want to add L prefix to STRING macro later in my code (I can't do it in definition). How to do it?
This should do:
#include <stdio.h>
#define CONCATENATE(e1, e2) e1 ## e2
#define PREFIX_L(s) CONCATENATE(L, s)
#define STRING "string"
int main(void)
{
printf("%ls\n", PREFIX_L(STRING));
}
These standard C pre-processor's concatenation capabilities are also covered by the documentation coming with GCC: https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html
This should work.
#define STRING(x) x"string"
char * l_pString = STRING("");
wchar_t * l_pWideString = STRING(L);