AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
156 stars 26 forks source link

Error building Tools on Linux #210

Closed pmprog closed 11 months ago

pmprog commented 11 months ago

Hi,

I get an error building the tools on Linux. Not sure what's wrong here. Any ideas?

Thanks

[ 64%] Building CXX object CMakeFiles/common.dir/src/common/sfx.cpp.o
In file included from /home/user/projects.amiga/ACE/tools/src/common/sfx.cpp:5:
/home/user/projects.amiga/ACE/tools/src/common/sfx.h: In constructor ‘constexpr tSfx::tSfx()’:
/home/user/projects.amiga/ACE/tools/src/common/sfx.h:45:19: error: call to non-‘constexpr’ function ‘std::vector<_Tp, _Alloc>::vector() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’
   45 |         m_ulFreq(0)
      |                   ^
In file included from /usr/include/c++/11/vector:67,
                 from /home/user/projects.amiga/ACE/tools/src/common/wav.h:9,
                 from /home/user/projects.amiga/ACE/tools/src/common/sfx.h:8,
                 from /home/user/projects.amiga/ACE/tools/src/common/sfx.cpp:5:
/usr/include/c++/11/bits/stl_vector.h:487:7: note: ‘std::vector<_Tp, _Alloc>::vector() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’ is not usable as a ‘constexpr’ function because:
  487 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:288:7: note: defaulted constructor calls non-‘constexpr’ ‘std::_Vector_base<_Tp, _Alloc>::_Vector_base() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’
  288 |       _Vector_base() = default;
      |       ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:288:7: note: ‘std::_Vector_base<_Tp, _Alloc>::_Vector_base() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’ is not usable as a ‘constexpr’ function because:
/usr/include/c++/11/bits/stl_vector.h:131:9: note: defaulted constructor calls non-‘constexpr’ ‘std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’
  131 |         _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
      |         ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:131:9: note: ‘std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = signed char; _Alloc = std::allocator<signed char>]’ declared here
make[2]: *** [CMakeFiles/common.dir/build.make:216: CMakeFiles/common.dir/src/common/sfx.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:131: CMakeFiles/common.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
timfel commented 11 months ago

Looks like your compiler is too old. GCC supports constexpr vector (a C++20 feature) since GCC 10

tehKaiN commented 11 months ago

There seems to be a problem with GCC version indeed.

@pmprog what's your linux distro? Something recent or dated? I'm asking 'cuz it'd be good to be supported by recent distro out of the box, so if I used too new cpp standard then I guess the code modernization needs to be toned down.

pmprog commented 11 months ago

I'm running Kubuntu 22.03 LTS gcc -version reports gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

tehKaiN commented 11 months ago

strange. I'll fix that soon!

tehKaiN commented 11 months ago

Looks like constexpr std::vector is supported since gcc12 (source). I've pushed a change which hopefully fixes this.