codereport / An-Algorithm-Library

A C++ algorithm library that extends the C++ standard algorithms found in <algorithm> & <numeric>
Boost Software License 1.0
22 stars 4 forks source link

add [[maybe_unused]] #9

Closed Sebanisu closed 3 years ago

Sebanisu commented 3 years ago

https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Warning-Options.html

-Wunused-function
Warn whenever a static function is declared but not defined or a non\-inline static function is unused.
-Wunused
All all the above -Wunused options combined.
In order to get a warning about an unused function parameter, you must either specify -W -Wunused or separately specify -Wunused-parameter.
-Werror
Make all warnings into errors.

I found gcc erroring, with unused and error turned on, if I'm including a hpp and a function isn't being used.

find doesn't need [[maybe_unused]] because it's used by found.

https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4505?view=msvc-160 Though on msvc it ignores [[maybe_unused]] So I had to suppress the warning. /wd4505 # suppress unreferenced local function has been removed.

Sebanisu commented 3 years ago

Maybe this doesn't need done. I'll read more about it. Could be my over use of the static keyword.

Sebanisu commented 3 years ago

So what I think is if the thing is static you might need maybe unused. But if it's not static you don't need it.