skypjack / uvw

Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!
MIT License
1.88k stars 211 forks source link

uv_type: supress `-Werror=unused` compiler error #296

Closed aloisklink closed 1 year ago

aloisklink commented 1 year ago

The uv_type() constructor does not use its token parameter, which causes a -Werror=unused compiler error on GCC (and probably on other compilers too).

~Luckily, C++17 adds the [[maybe_unused]] attribute that all standards compliant compilers will support to hide unused errors.~ Removed, see https://github.com/skypjack/uvw/pull/296#issuecomment-1686169140.


This fixes the error reported in https://github.com/skypjack/uvw/issues/294#issuecomment-1683625763, but I didn't want to add a Fixes: #294 into my commit or PR, since it seems like that issue is more about disabling all potential warnings using CMake, not just this single error.

skypjack commented 1 year ago

Oh, well, since the parameter name is the same of the type, I'd just drop the first one. As in:

explicit uv_type(loop::token, std::shared_ptr<loop> ref) noexcept

Rather than:

explicit uv_type([[maybe_unused]] loop::token token, std::shared_ptr<loop> ref) noexcept
aloisklink commented 1 year ago

Oh, well, since the parameter name is the same of the type, I'd just drop the first one.

That makes sense! You only really need [[maybe_unused]] if you need to give the parameter a name (e.g. for Doxygen). I've fixed this in https://github.com/skypjack/uvw/pull/296/commits/619bf5d9a0fa6cfa3174ef1ec879e2790b13c5a9, and I've updated the commit/PR description to remove any references to [[maybe_unused]].

skypjack commented 1 year ago

Thank you (and sorry for the late reply, I'm out of home).

aloisklink commented 1 year ago

Thank you (and sorry for the late reply, I'm out of home).

No worries! 2 days isn't really a late reply! I might take a while to reply too, since although we're generally allowed to submit patches to open-source, we're only allowed to do it in our personal time!