craffael / lehrfempp

Simple Finite Element Framework for research and education
MIT License
28 stars 16 forks source link

lehrfempp not compiling; span.h:1499:15: error: missing binary operator before token "(" #206

Closed Fytch closed 9 months ago

Fytch commented 3 years ago

Yet again, lehrfempp does not compile. After a long search, I've reduced the error to the following snippet:

#include <lf/mesh/mesh.h>
int main()
{
}

Relevant compiler call:

cd /home/fytch/ETH/BA/lehrfempp_fresh/build-Debug/projects/Cohomology && /usr/bin/c++ -DBOOST_ENABLE_ASSERT_DEBUG_HANDLER -DFMT_LOCALE -DLF_REDIRECT_ASSERTS -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -I/home/fytch/ETH/BA/lehrfempp_fresh/lib -I/home/fytch/ETH/BA/lehrfempp_fresh/build-Debug/_deps/quiver-src/include -isystem /home/fytch/.hunter/_Base/093bd9a/cb3d9e0/84133a3/Install/include/eigen3 -isystem /home/fytch/.hunter/_Base/093bd9a/cb3d9e0/84133a3/Install/include -g -std=c++20 -MD -MT projects/Cohomology/CMakeFiles/Cohomology_test.dir/test.cpp.o -MF CMakeFiles/Cohomology_test.dir/test.cpp.o.d -o CMakeFiles/Cohomology_test.dir/test.cpp.o -c /home/fytch/ETH/BA/lehrfempp_fresh/projects/Cohomology/test.cpp

Compiler output:

[100%] Building CXX object projects/Cohomology/CMakeFiles/Cohomology_test.dir/test.cpp.o
In file included from /home/fytch/ETH/BA/lehrfempp_fresh/lib/lf/base/base.h:56,
                 from /home/fytch/ETH/BA/lehrfempp_fresh/lib/lf/mesh/entity.h:4,
                 from /home/fytch/ETH/BA/lehrfempp_fresh/lib/lf/mesh/mesh.h:22,
                 from /home/fytch/ETH/BA/lehrfempp_fresh/projects/Cohomology/test.cpp:1:
/home/fytch/ETH/BA/lehrfempp_fresh/lib/lf/base/span.h:1499:15: error: missing binary operator before token "("
 1499 |     (span_HAVE(BYTE) || span_HAVE(NONSTD_BYTE))
      |               ^
make[3]: *** [projects/Cohomology/CMakeFiles/Cohomology_test.dir/build.make:76: projects/Cohomology/CMakeFiles/Cohomology_test.dir/test.cpp.o] Error 1

Compiler version:

Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC) 
craffael commented 3 years ago

I tried to reproduce your example but for me it successfully compiled with g++-11. I took the source code and executed the following commands:

export CXX=g++-11
mkdir build
cd build
cmake ..
make

Can you try whether this also works on your machine? Or can you provide me with a complete example (in the form of a zip file) that I can try on my machine?

Fytch commented 3 years ago

I was able to compile your example and I have been able to track down the key difference between your example and my project: C++20. After adding set(CMAKE_CXX_STANDARD 20) to the CMakeLists.txt file that you have have provided, the same error occurs again:

Consolidate compiler generated dependencies of target getting_started
[ 50%] Building CXX object CMakeFiles/getting_started.dir/main.cc.o
In file included from /home/fytch/.hunter/_Base/093bd9a/cb3d9e0/9d0461e/Install/include/lf/base/base.h:56,
                 from /home/fytch/.hunter/_Base/093bd9a/cb3d9e0/9d0461e/Install/include/lf/mesh/entity.h:4,
                 from /home/fytch/.hunter/_Base/093bd9a/cb3d9e0/9d0461e/Install/include/lf/mesh/mesh.h:22,
                 from /tmp/tmp.5p8U0hwfNe/main.cc:1:
/home/fytch/.hunter/_Base/093bd9a/cb3d9e0/9d0461e/Install/include/lf/base/span.h:1499:15: error: missing binary operator before token "("
 1499 |     (span_HAVE(BYTE) || span_HAVE(NONSTD_BYTE))
      |               ^
make[2]: *** [CMakeFiles/getting_started.dir/build.make:76: CMakeFiles/getting_started.dir/main.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/getting_started.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Fytch commented 3 years ago

Clang 12 reports the same problem with C++20 enabled:

In file included from /tmp/tmp.5p8U0hwfNe/main.cc:1:
In file included from /home/fytch/.hunter/_Base/093bd9a/fa1abb1/9d0461e/Install/include/lf/mesh/mesh.h:22:
In file included from /home/fytch/.hunter/_Base/093bd9a/fa1abb1/9d0461e/Install/include/lf/mesh/entity.h:4:
In file included from /home/fytch/.hunter/_Base/093bd9a/fa1abb1/9d0461e/Install/include/lf/base/base.h:56:
/home/fytch/.hunter/_Base/093bd9a/fa1abb1/9d0461e/Install/include/lf/base/span.h:1499:6: error: function-like macro 'span_HAVE' is not defined
    (span_HAVE(BYTE) || span_HAVE(NONSTD_BYTE))
     ^
1 error generated.
make[2]: *** [CMakeFiles/getting_started.dir/build.make:76: CMakeFiles/getting_started.dir/main.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/getting_started.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Compiler version:

clang version 12.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
craffael commented 3 years ago

Okay, I think the problem is resolved, at least the small sample program that you provided compiles now in c++20 mode. If you use LehrFEM++ via hunter in your project, you will have to use the absolutely latest version (de186a85b1824f669f6deb5033f3c9bdafb6abed) of the master branch (see "Use Cutting Edge Version of LehrFEM++" in the getting started guide).

Can you please check if it works for you now?

Fytch commented 3 years ago

Thank you for looking into this! I will come back to you in a couple of days after I've had my last exam.