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

Build error: keyword is hidden by macro definition! #1985

Closed
ClausKlein opened this issue Mar 13, 2020 · 8 comments · Fixed by #2352
Closed

Build error: keyword is hidden by macro definition! #1985

ClausKlein opened this issue Mar 13, 2020 · 8 comments · Fixed by #2352
Assignees
Labels
release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@ClausKlein
Copy link

This is BAD code style:

cmake --build ../.build-json-Debug
[0/1] Re-running CMake...
-- use ccache
-- clang-tidy found: /opt/local/bin/clang-tidy
-- cmake source dir: /Users/clausklein/Workspace/cpp/json
-- check target added
-- Using the single-header code from /Users/clausklein/Workspace/cpp/json/single_include/
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clausklein/Workspace/cpp/.build-json-Debug
[1/83] Building CXX object test/CMakeFiles/test-unicode.dir/src/unit-unicode.o
FAILED: test/CMakeFiles/test-unicode.dir/src/unit-unicode.o 
/opt/local/bin/ccache /opt/local/bin/clang++  -DDOCTEST_CONFIG_SUPER_FAST_ASSERTS -I/Users/clausklein/Workspace/cpp/json/test/thirdparty/doctest -I/Users/clausklein/Workspace/cpp/json/test/thirdparty/fifo_map -I/Users/clausklein/Workspace/cpp/json/single_include -g   -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-float-equal -std=c++17 -MMD -o test/CMakeFiles/test-unicode.dir/src/unit-unicode.o -c /Users/clausklein/Workspace/cpp/json/test/src/unit-unicode.cpp
/Users/clausklein/Workspace/cpp/json/test/src/unit-unicode.cpp:35:9: error: keyword is hidden by macro definition [-Werror,-Wkeyword-macro]
#define private public
        ^
1 error generated.
[3/83] Building CXX object test/CMakeFiles/test-udt.dir/src/unit-udt.o
ninja: build stopped: subcommand failed.
make: *** [GNUmakefile:75: all] Fehler 1
@ClausKlein
Copy link
Author

There are more Warnings with Clang 9.0.0

[58/85] Building CXX object test/CMakeFiles/test-noexcept.dir/src/unit-noexcept.o
/Users/clausklein/Workspace/cpp/json/test/src/unit-noexcept.cpp:45:6: warning: function 'to_json' is not needed and will not be emitted [-Wunneeded-internal-declaration]
void to_json(json&, pod) noexcept;
     ^
/Users/clausklein/Workspace/cpp/json/test/src/unit-noexcept.cpp:46:6: warning: function 'to_json' is not needed and will not be emitted [-Wunneeded-internal-declaration]
void to_json(json&, pod_bis);
     ^
/Users/clausklein/Workspace/cpp/json/test/src/unit-noexcept.cpp:47:6: warning: function 'from_json' is not needed and will not be emitted [-Wunneeded-internal-declaration]
void from_json(const json&, pod) noexcept;
     ^
/Users/clausklein/Workspace/cpp/json/test/src/unit-noexcept.cpp:48:6: warning: function 'from_json' is not needed and will not be emitted [-Wunneeded-internal-declaration]
void from_json(const json&, pod_bis);
     ^
4 warnings generated.

@nlohmann
Copy link
Owner

The bad code style is not in productive code, but in the test suite, which needs access to private members to achieve 100% code coverage. I would be happy to use a different approach (without refactoring the library).

The -Wunneeded-internal-declaration warnings could be resolved by removing the declaration, but then GCC will warn about missing declarations. I am not sure what do do about that.

Any suggestions?

@tete17
Copy link
Contributor

tete17 commented Mar 15, 2020

If all you are doing it being a consumer of the library and not a developer of it you an allway disable the build of the with this cmake flag JSON_BuildTests.

That should get rid of most of those warnings

@ClausKlein
Copy link
Author

ClausKlein commented Mar 16, 2020 via email

@nlohmann
Copy link
Owner

Hm. I read about this once, but never followed up. Interesting! I'll see if I can make this work.

@stale
Copy link

stale bot commented Apr 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Apr 18, 2020
@nlohmann
Copy link
Owner

I am not sure whether it is worth investing time to get rid of warnings in the test suite. PRs welcome, though.

@stale stale bot removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Apr 19, 2020
@stale
Copy link

stale bot commented May 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label May 19, 2020
@stale stale bot closed this as completed May 30, 2020
@nlohmann nlohmann added release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation and removed state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated labels Aug 12, 2020
@nlohmann nlohmann added this to the Release 3.9.2 milestone Aug 12, 2020
@nlohmann nlohmann self-assigned this Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants