Accepting "%@" in format string with __attribute__ format
Cedric Roux
cedric.roux@acri-st.fr
Tue Mar 9 15:05:00 GMT 2010
Manfred Schwind wrote:
> Is there any chance to get gcc check my passed parameters the
> "Objective-C way" with "%@" included but still having the format
> string passed as plain old C-string? It there any other types
> than __NSString__ I could try?
>
> BTW, is there an official list what types are accepted by __attribute__((format(...))) ?
This NSString does not seem to be recognized by gcc at all.
I see that llvm handles it.
(http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?revision=97103&view=markup)
Are you sure you use gcc?
Compiling:
#import <Foundation/Foundation.h>
void mlog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
leads to:
toto.m:3: warning: ‘__NSString__’ is an unrecognized format function type
with gcc 4.4 and GNUstep stuff.
Apart from that, the gcc documentation tells what types you can use in __attribute__ format
stuff. (Here when I do "info gcc", in the C Extensions -> Function Attributes it is
described and allowed stuff is:
`printf', `scanf', `strftime',
`gnu_printf', `gnu_scanf', `gnu_strftime' or `strfmon'. (You can
also use `__printf__', `__scanf__', `__strftime__' or
`__strfmon__'.) On MinGW targets, `ms_printf', `ms_scanf', and
`ms_strftime' are also present.
)
My .1 euros...
More information about the Gcc-help
mailing list