This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ObjC: attributes on methods
- From: Ziemowit Laski <zlaski at apple dot com>
- To: "Timothy J. Wood" <tjw at omnigroup dot com>
- Cc: gcc at gcc dot gnu dot org, snaroff at apple dot com
- Date: Mon, 11 Mar 2002 00:32:06 -0800
- Subject: Re: ObjC: attributes on methods
On Sunday, March 10, 2002, at 04:46 , Timothy J. Wood wrote:
>
>
> It doesn't look like attributes can be applied to ObjC methods:
>
> @interface Foo
> + (void) printf: (const char *) fmt, ... __attribute__ ((format
> (printf, 3, 4)));
> @end
>
> Is there any major reason for this, or is it just because no one has
> wanted it before?
The latter. :) Well, I take that back -- I do recall seeing a feature
request like this in the internal Apple database, the final goal being
to have GCC type-check the arguments following the format string, just
as for the ordinary "C" printf and friends. (I assume this is what
you're aiming at also, right?)
While I do see the appeal of this, I did manage to come up with a
wrinkle. Suppose that you have also defined
@interface Bar
+ (void) printf: (const char *)format, ...;
@end
WITHOUT the __attribute__(...) specification and then, somewhere else
still, you constructed the message
[someObj printf:"%s %d\n", arg1, arg2];
what should the compiler do? In the general case, it won't be able to
tell whether to perform the argument "type-checking" or not.
My thoughts,
--Zem