Skip to content

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

Description

@ClausKlein

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

Activity

  1. ClausKlein commented on Mar 13, 2020

    @ClausKlein
    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.
  2. nlohmann commented on Mar 14, 2020

    @nlohmann
    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?

  3. tete17 commented on Mar 15, 2020

    @tete17
    Contributor

    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

  4. ClausKlein commented on Mar 16, 2020

    @ClausKlein
    Author
  5. nlohmann commented on Mar 19, 2020

    @nlohmann
    Owner

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

  6. stale commented on Apr 18, 2020

    @stale

    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.

  7. added
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on Apr 18, 2020
  8. nlohmann commented on Apr 19, 2020

    @nlohmann
    Owner

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

  9. removed
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on Apr 19, 2020
  10. stale commented on May 19, 2020

    @stale

    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.

  11. added
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on May 19, 2020
  12. added
    solution: proposed fixa fix for the issue has been proposed and waits for confirmation
    and removed
    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated
    on Aug 12, 2020
  13. added this to the Release 3.9.2 milestone on Aug 12, 2020
  14. self-assigned this
    on Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions