Blake-Madden / Wisteria-Dataviz

Wisteria Dataviz Library
BSD 3-Clause "New" or "Revised" License
15 stars 3 forks source link

Remove [[nodiscard]] attribute from methods returning void #14

Closed PBfordev closed 2 years ago

PBfordev commented 2 years ago

Without this change, the build fails with MSVC (2017), since Wisteria CMakefile tells the compiler to treat warnings as errors:

1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1301): error C2220: warning treated as error - no 'object' file generated
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1301): warning C4834: discarding return value of function with 'nodiscard' attribute
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1301): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1317): warning C4834: discarding return value of function with 'nodiscard' attribute
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1317): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1450): warning C4834: discarding return value of function with 'nodiscard' attribute
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1450): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1672): warning C4834: discarding return value of function with 'nodiscard' attribute
1>D:\dev\Desktop\Lib\Wisteria-Dataviz-GIT\src\base\reportbuilder.cpp(1672): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
1>Done building project "Wisteria.vcxproj" -- FAILED.

Other compilers could warn when the function is just declared, not even called.

EDIT These warnings are not present in MSVS 2022 (v17.3.3). With GCC 12.2, the attribute warning is there and GCC also warns that attribute usage is incorrect in method declaration (between static and return type). There are also many other GCC warnings and not all of them are -Wreorder.

Blake-Madden commented 2 years ago

I'll try to recompile on OpenSUSE this weekend and fix any new GCC warnings, thanks for the heads up.