Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark project files as SYSTEM when not standalone #158

Closed
andrewkcorcoran opened this issue May 3, 2021 · 4 comments
Closed

Mark project files as SYSTEM when not standalone #158

andrewkcorcoran opened this issue May 3, 2021 · 4 comments

Comments

@andrewkcorcoran
Copy link

Currently user code compiled with -Wshadow is failing when trying to use toml due to warnings in toml/types.hpp. CMake has an inbuilt mechanism (SYSTEM) to suppress warnings in header files of third party libraries. This should be enabled for toml to prevent issues in header files from breaking users who use the library from source. See https://github.com/microsoft/GSL/blob/main/include/CMakeLists.txt as an example.

toml/types.hpp:44:24: error: declaration of ‘boolean’ shadows a global declaration [-Werror=shadow]
toml/types.hpp:24:7: note: shadowed declaration is here
@ToruNiina
Copy link
Owner

Thank you for reporting the issue, I reproduced it.
If I'm not mistaken, the reason of the warning is the name of enum class toml::value_t; and typedefs. I think it is difficult to avoid the problem without changing the name of enumerator names and type names, but it is also difficult to change the typenames for the sake of backward compatibility. So I think I need to, as you said, inform users to set SYSTEM in target_include_directories to avoid this issue. I will add it to the README. I will also consider to add some pragmas to avoid this issue automatically.

I also found that it passes the tests if we reduced the level of warning as -Wshadow=local in a particular version of gcc in my local machine. I will examine a bit more and add the warning to the CI build if possible.

Thank you again!

@andrewkcorcoran
Copy link
Author

andrewkcorcoran commented May 4, 2021 via email

@ToruNiina
Copy link
Owner

I have suppressed the error related to -Wshadow at the level of soruce code, and added -Wshadow to tests/CMakeLists.txt to check it automatically on CI services.

@andrewkcorcoran
Copy link
Author

Hi toml is failing to compile again with -Werror=free-nonheap-object. The root solution to this is that we need to make all toml files as system when toml is included as a subdirectory. Can we reopen this please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants