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

precompiled compilation failed due to spec.hpp #246

Closed
zhuzhzh opened this issue Jun 18, 2024 · 2 comments
Closed

precompiled compilation failed due to spec.hpp #246

zhuzhzh opened this issue Jun 18, 2024 · 2 comments

Comments

@zhuzhzh
Copy link

zhuzhzh commented Jun 18, 2024

Here is my step.

% git clone https://github.com/ToruNiina/toml11
% cd toml11
% git submodule update --init --recursive
% mkdir build && cd build
% cmake -DCMAKE_INSTALL_PREFIX=/home/public/toml11-v4.0.0 -DTOML11_PRECOMPILE=ON  -DCMAKE_CXX_STANDARD=17 ../
-- The CXX compiler identification is GNU 11.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/rh/devtoolset-11/root/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (2.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/harriszh/install/toml11/build
% make
[  5%] Building CXX object src/CMakeFiles/toml11.dir/color.cpp.o
[ 11%] Building CXX object src/CMakeFiles/toml11.dir/context.cpp.o
In file included from /usr/include/sys/types.h:222,
                 from /usr/include/stdlib.h:314,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/cstdlib:75,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/stl_algo.h:59,
                 from /opt/rh/devtoolset-11/root/usr/include/c++/11/algorithm:62,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../fwd/../fwd/../compat.hpp:6,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../fwd/../fwd/../result.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../fwd/../fwd/location_fwd.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../fwd/../location.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../fwd/region_fwd.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/../region.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../fwd/source_location_fwd.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/../source_location.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/fwd/error_info_fwd.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/error_info.hpp:4,
                 from /home/harriszh/install/toml11/include/toml11/context.hpp:4,
                 from /home/harriszh/install/toml11/src/context.cpp:1:
/home/harriszh/install/toml11/include/toml11/spec.hpp: In constructor ‘constexpr toml::semantic_version::semantic_version(uint32_t, uint32_t, uint32_t)’:
/home/harriszh/install/toml11/include/toml11/spec.hpp:15:11: error: class ‘toml::semantic_version’ does not have any field named ‘gnu_dev_major’
   15 |         : major(mjr), minor(mnr), patch(p)
      |           ^~~~~
/home/harriszh/install/toml11/include/toml11/spec.hpp:15:23: error: class ‘toml::semantic_version’ does not have any field named ‘gnu_dev_minor’
   15 |         : major(mjr), minor(mnr), patch(p)
      |                       ^~~~~
In file included from /home/harriszh/install/toml11/include/toml11/context.hpp:5,
                 from /home/harriszh/install/toml11/src/context.cpp:1:
/home/harriszh/install/toml11/include/toml11/spec.hpp:16:6: error: member ‘toml::semantic_version::major’ must be initialized by mem-initializer in ‘constexpr’ constructor
   16 |     {}
      |      ^
/home/harriszh/install/toml11/include/toml11/spec.hpp:18:19: note: declared here
   18 |     std::uint32_t major;
      |                   ^~~~~
/home/harriszh/install/toml11/include/toml11/spec.hpp:16:6: error: member ‘toml::semantic_version::minor’ must be initialized by mem-initializer in ‘constexpr’ constructor
   16 |     {}
      |      ^
/home/harriszh/install/toml11/include/toml11/spec.hpp:19:19: note: declared here
   19 |     std::uint32_t minor;
      |                   ^~~~~
make[2]: *** [src/CMakeFiles/toml11.dir/build.make:90: src/CMakeFiles/toml11.dir/context.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:854: src/CMakeFiles/toml11.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I searched 'gnu_dev_major' in the whole directory, but didn't find anything.

My vim install LSP tool (clang), which shows the same error messages as above.

@ToruNiina
Copy link
Owner

Thank you for trying it and reporting the error!

I reproduced the error by adding #include <sys/sysmacros.h> that defines #define major(dev) gnu_dev_major (dev) that takes over the major(mjr).
To avoid unintended macro expansion, I changed major(mjr) to major{mjr}. It now compiles with <sys/sysmacros.h>. I think the problem is resolved.

@zhuzhzh
Copy link
Author

zhuzhzh commented Jun 19, 2024

@ToruNiina Thanks. After changing to major{mjr}, minor{mnr}, patch{p}, the compilation passes.

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