Hi all, I was working on some C++11 template hacks to be able to pass C++ objects to a function wrapping printf. What I want to do looks like this, where convert might do fancy things like create string representations of objects:
template<typename... Args> void Printf(const char* format, Args&&... args) { printf(format, convert(std::forward<Args>(args))...); } However, it seems that this is incompatible with the __attribute__((format(printf, 1, 2))) applied to printf. When trying to call this function as Printf("%d\n", 3); I get the following errors: In function 'void Printf(const char*, Args&& ...) [with Args = int]': instantiated from here warning: format not a string literal, argument types not checked Unfortunately, the compiler believes my format string is not a string literal, but it is! It's really important to me that the arguments are checked against the format string at compile time, as this catches serious bugs sooner. I tried this on gcc-4.4 through 4.7 (and clang 3.0), with the same result. Is this a compiler bug? Is there a work-around for this problem? Thanks, Diego