__attribute__ ((format (printf, ...))) doesn't work in C++ methods
Marko Mäkelä
Marko.Makela@HUT.FI
Fri Aug 21 05:34:00 GMT 1998
Dear Sirs,
I have my own printf () like function, and would like g++ (I'm using
GNU g++ 2.7.2.1 and egcs-2.90.29 980515 (egcs-1.0.3 release)) to check
its parameters. The following works fine in a global C function:
void
print (unsigned indent, const char* fmt, ...)
# ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
# endif // __GNUC__
;
The __attribute__ thing is also accepted by the compiler when I make
this function a static member function of a C++ class, but no warning
messages will be generated for mismatches between the printf format
string and the parameters. If I make the function a non-static
member, I have to increment the parameters by one, e.g.
__attribute__ ((format (printf, 3, 4)))
for the above function. I guess that the "this" pointer is counted as
the 1st parameter in this case.
I hope that you can reproduce the bug with the above information. If
not, I will gladly supply you with example code that demonstrates the
problem.
With best regards,
Marko Mäkelä
More information about the Gcc-bugs
mailing list