This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
__attribute__ ((format (printf, ...))) doesn't work in C++ methods
- To: bug-g++ at prep dot ai dot mit dot edu, egcs-bugs at cygnus dot com
- Subject: __attribute__ ((format (printf, ...))) doesn't work in C++ methods
- From: Marko Mäkelä <Marko dot Makela at HUT dot FI>
- Date: Fri, 21 Aug 1998 15:34:46 +0300 (EEST)
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ä