This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

__attribute__ ((format (printf, ...))) doesn't work in C++ methods

Dear Sirs,

I have my own printf () like function, and would like g++ (I'm using
GNU g++ and egcs-2.90.29 980515 (egcs-1.0.3 release)) to check
its parameters.  The following works fine in a global C function:

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

With best regards,

	Marko Mäkelä

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]