[webkit-dev] maybe_unused vs UNUSED_PARAM

Anne van Kesteren annevk at annevk.nl
Wed Jan 24 23:59:43 PST 2024


I had a [[fallthrough]] patch, but internal C code got in the way:

- https://en.cppreference.com/w/c/language/attributes/fallthrough
- https://bugs.webkit.org/show_bug.cgi?id=265789

Using them directly where we can seems nice for (new) readers of the code at least. Not sure what a macro for [[fallthrough]] would buy us for instance.

> On Jan 25, 2024, at 12:28 AM, Ryosuke Niwa via webkit-dev <webkit-dev at lists.webkit.org> wrote:
> 
> If we’re adopting [[maybe_unused]], do we just write that directly in each function declaration / definition? Or do we define some a macro to do that anyway?
> 
> What bout other kinds of attributes like [[noreturn]], [[fallthrough]], and [[likely]]? Are we gonna start writing them directly in code, or are we gonna continue to use macros?
> 
> - R. NIwa
> 
>> On Jan 24, 2024, at 9:49 AM, Chris Dumez via webkit-dev <webkit-dev at lists.webkit.org> wrote:
>> 
>> Hi,
>> 
>> Thanks for starting this discussion.
>> 
>> I personally think it would be nice for us to switch to [[maybe_unused]] since it is now part of the language and it seems to fit our needs. However, I do think we should be consistent and stop using UNUSED_PARAM() / ASSERT_UNUSED() in new code entirely then.
>> 
>> So if we decide to switch, I think should add style checks to prevent using UNUSED_PARAM() / ASSERT_UNUSED() and recommend using [[maybe_unused]] instead. Eventually, we should try to phase out existing usage of these macros so that we can remove them entirely.
>> 
>> Cheers,
>> Chris.
>> 
>>> On Jan 24, 2024, at 9:34 AM, Alex Christensen via webkit-dev <webkit-dev at lists.webkit.org> wrote:
>>> 
>>> For many years we have used the UNUSED_PARAM macros, and we have almost 3000 of them.  C++17 introduced [[maybe_unused]] for this purpose, and a few uses of it are starting to pop up in WebKit.  Should we switch, should we transition, should we allow both, or should we just stick with UNUSED_PARAM?
>>> _______________________________________________
>>> webkit-dev mailing list
>>> webkit-dev at lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>> 
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20240125/303da2b8/attachment.htm>


More information about the webkit-dev mailing list