Reputation:
I'm trying to write a simple macro to append a break line to it. Is it the right do this?:
#define DEBUG_PRINT(message, ...) \
message += "\n"; \
_RPTN(0, message, __VA_ARGS__)
And to use:
DEBUG_PRINT("my messages %s %d", anotherString, someNumber)
Also for some reason the compiler doesn't accepts it with a message:
Cannot assign to an array type 'char const[theSizeOfTheString]'
Thanks for the answers in advance! :)
Upvotes: 0
Views: 294
Reputation: 1613
If you know that message
is going to be a constant string, you could do it like this:
#define DEBUG_PRINT(message, ...) _RPTN(0, message "\n", __VA_ARGS__)
For more details, see string literals at cppreference:
String literals placed side-by-side are concatenated at translation phase 6 (after the preprocessor). That is,
"Hello," " world!"
yields the (single) string"Hello, world!"
. If the two strings have the same encoding prefix (or neither has one), the resulting string will have the same encoding prefix (or no prefix).
Upvotes: 1