> On Mar 16, 2016, at 6:54 AM, Laszlo Ersek <ler...@redhat.com> wrote:
> 
> On 03/14/16 16:38, Leif Lindholm wrote:
>> To permit many existing platforms to build with -Wunused-parameter, on
>> GCC and CLANG, the unused parameters need to be annotated as such.
>> Existing regexp code already uses ARG_UNUSED for this, but it is really
>> needed across the codebase - so add a version in Base.h.
>> 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Leif Lindholm <leif.lindh...@linaro.org>
>> ---
>> 
>> This is really the result of a friendly toolchain engineer informing me
>> CLANG has the -Weverything flag, to actually enable all possible
>> warnings.
>> 
>> One problem trying to pick out the real bugs from the just not entirely
>> clear code is that basically a lot of *LibNull implementations, and
>> some libraries that should be usable, trip build failures due to unused
>> parameters.
>> 
>> MdePkg/Include/Base.h | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>> 
>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>> index 89b2aed..f789094 100644
>> --- a/MdePkg/Include/Base.h
>> +++ b/MdePkg/Include/Base.h
>> @@ -189,6 +189,15 @@ struct _LIST_ENTRY {
>> ///
>> #define OPTIONAL
>> 
>> +///
>> +/// Function argument intentionally unused in function.
>> +///
>> +#if defined(__GNUC__) || defined(__clang__)
>> +  #define ARG_UNUSED  __attribute__ ((unused))
>> +#else
>> +  #define ARG_UNUSED
>> +#endif
>> +
>> //
>> //  UEFI specification claims 1 and 0. We are concerned about the
>> //  complier portability so we did it this way.
>> 
> 
> Support for this seems to go back to gcc-4.4:
> 
> https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Variable-Attributes.html
> 
> So it looks safe. (And I agree with the idea.)
> 

I'm confused by the usage, or really when the compiler detects the warning? 

For example how is this going to work on public interfaces? Protocols, PPIs,  
or library class definitions? There is a single definition of the function, but 
multiple implementations. Some implementations may not use some arguments. But 
what arguments get used seems to be an implementation choice and not part of 
the API? Thus it seems like this macro is not going to enable changing compiler 
flags?

Or am I just confused?

Thanks,

Andrew Fish
 

> Acked-by: Laszlo Ersek <ler...@redhat.com>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to