xva-img icon indicating copy to clipboard operation
xva-img copied to clipboard

Something about C++11

Open AndreKR opened this issue 3 years ago • 1 comments

Sorry about the vague title but I am not too familiar with how version selection works with CMake or C++ in general.

I just built xva-img on Ubuntu Xenial.

Initially I got errors, these with GCC:

[ 12%] Building CXX object CMakeFiles/xva-img.dir/src/disk.cpp.o
In file included from xva-img-1.4.2/src/disk.cpp:48:0:
xva-img-1.4.2/src/disk.hpp:45:5: warning: identifier ‘noexcept’ is a keyword in C++11 [-Wc++0x-compat]
     noexcept(false);
     ^
xva-img-1.4.2/src/disk.hpp:44:43: error: expected ‘;’ at end of member declaration
    bool Export(const std::string& diskpath)
                                           ^
xva-img-1.4.2/src/disk.hpp:45:14: error: expected identifier before ‘false’
     noexcept(false);
              ^
xva-img-1.4.2/src/disk.hpp:45:14: error: expected ‘,’ or ‘...’ before ‘false’
xva-img-1.4.2/src/disk.hpp:45:19: error: ISO C++ forbids declaration of ‘noexcept’ with no type [-fpermissive]
     noexcept(false);
                   ^
xva-img-1.4.2/src/disk.hpp:46:43: error: expected ‘;’ at end of member declaration
    bool Import(const std::string& diskpath)
                                           ^
xva-img-1.4.2/src/disk.hpp:47:14: error: expected identifier before ‘false’
     noexcept(false);
              ^
xva-img-1.4.2/src/disk.hpp:47:14: error: expected ‘,’ or ‘...’ before ‘false’
xva-img-1.4.2/src/disk.hpp:47:19: error: ISO C++ forbids declaration of ‘noexcept’ with no type [-fpermissive]
     noexcept(false);
                   ^
xva-img-1.4.2/src/disk.hpp:47:5: error: ‘int XVA::Disk::noexcept(int)’ cannot be overloaded
     noexcept(false);
     ^
xva-img-1.4.2/src/disk.hpp:45:5: error: with ‘int XVA::Disk::noexcept(int)’
     noexcept(false);
     ^
xva-img-1.4.2/src/disk.cpp:60:2: error: expected initializer before ‘noexcept’
  noexcept(false)
  ^
CMakeFiles/xva-img.dir/build.make:62: recipe for target 'CMakeFiles/xva-img.dir/src/disk.cpp.o' failed

and these with Clang:

[ 12%] Building CXX object CMakeFiles/xva-img.dir/src/disk.cpp.o
In file included from xva-img-1.4.2/src/disk.cpp:48:
xva-img-1.4.2/src/disk.hpp:44:44: error: expected ';' at end of declaration list
                        bool Export(const std::string& diskpath)
                                                                ^
                                                                ;
xva-img-1.4.2/src/disk.hpp:46:44: error: expected ';' at end of declaration list
                        bool Import(const std::string& diskpath)
                                                                ^
                                                                ;
xva-img-1.4.2/src/disk.cpp:60:2: error: expected function body after function declarator
        noexcept(false)
        ^
3 errors generated.
CMakeFiles/xva-img.dir/build.make:62: recipe for target 'CMakeFiles/xva-img.dir/src/disk.cpp.o' failed

The solution was to run cmake -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON . instead of just cmake .. This makes it build with both GCC and Clang.

AndreKR avatar Jun 06 '21 22:06 AndreKR

Thanks for the report and the effort to find a workaround on older compilers!

eriklax avatar Jun 10 '21 09:06 eriklax