This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFI]: getting objc to grok attributes ??
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: nicola at brainstorm dot co dot uk
- Cc: gcc at gcc dot gnu dot org, gnustep-dev at gnu dot org, jsm28 at cam dot ac dot uk, ovidiu at cup dot hp dot com, shebs at apple dot com
- Date: Mon, 17 Jun 2002 10:33:13 -0400 (EDT)
- Subject: Re: [RFI]: getting objc to grok attributes ??
- References: <Pine.LNX.4.21.0206171032400.27502-100000@nicola.brainstorm.co.uk>
> From: Nicola Pero <nicola@brainstorm.co.uk>
Nicola - Thanks for all of your comments/feedback!
> [...]
> The reason is that, while in C you define a function and normally the
> function has a single implementation associated with it (so, if an
> argument is unused, it's suspicious that there might be a mismatch between
> the declaration and the implementation, and it's a good idea to warn), in
> ObjC is very common to define a method in a place and have many different
> implementations of the method in many different classes. For example -
Yes, C++ (whose syntax I do know) is much the same. In C++, one can
omit function/method parameter names when they are unused and g++
avoids warning in these cases. E.g.
> int foo (int a, int, char *)
> { return a; }
Here g++ will not warn about the unused 2nd and 3rd arguments. I
don't know objc syntax to suggest a similar mechanism. (It may not be
possible, if you can omit the type there's no argument placeholder?)
> Depending on the semantics of __attribute__ ((__unused__)) [does it mark
> the argument as being possibly unused in that method implementation, or is
> it a system-wide declaration that in all implementations of methods with
> that name/signature the argument could be unused ?],
In frontends where its currently implemented, attributes on parameters
are specific to the exact function or method where one uses it. I
would expect that if we extend objc to allow it we would follow this
convention.
> So, maybe (from an ObjC user point of view) we should better disable the
> warnings for unused method arguments, unless some -Wxxx option is included
> to cause them (my bet is nobody will ever want to use that option, but
> anyway).
If that's the consensus among objc developers fine, but I'm not sure I
like it and its beyond what I would be interested in implementing.
Its too blunt, I prefer a clean way of specifying which unused
identifiers are ignorable and warn about anything else.
Can you perhaps suggest something based on the C++ example I gave?
--Kaveh
--
Kaveh R. Ghazi Director of Systems Architecture
ghazi@caip.rutgers.edu Qwest Solutions