Variadic Macro: cannot pass objects of non-trivially-copyable type through '…'
问题 I am trying to write a macro for logging mechanism. I wrote a variadic macro but it does not work with std::string . The code looks like the following: #include <stdio.h> #include <string> #define LOG_NOTE(m, ...) printf(m, ##__VA_ARGS__) int main() { std::string foo = "random string"; int bar = 5; LOG_NOTE("%s %d %s", "Hello World", bar, foo); return 0; } If I would call the macro like following, I would not get any error. LOG_NOTE("%s %d %s", "Hello World", bar, "random string"); Compiler