0

Im only trying my tutorial to try catch2 unit testing lib. Im using mac with 10.14. I dont have full XCode, only cmd tools and macports runs perfect in my setup (no brew). Im using the amalgamated single header and source file as suggested.

Yet, a simple tutorial:

#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"

unsigned int Factorial( unsigned int number ) {
    return number <= 1 ? number : Factorial(number-1)*number;
}


TEST_CASE( "Factorials are computed", "[factorial]" ) {
    REQUIRE( Factorial(1) == 1 );
    REQUIRE( Factorial(2) == 2 );
    REQUIRE( Factorial(3) == 6 );
    REQUIRE( Factorial(10) == 3628800 );
}

gives many compile errors - snip:

In file included from test1.cpp:2:
./catch.hpp:75:49: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
            NonCopyable( NonCopyable const& ) = delete;
                                                ^
./catch.hpp:76:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
            NonCopyable( NonCopyable&& ) = delete;
                                    ^
./catch.hpp:76:44: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
            NonCopyable( NonCopyable&& ) = delete;
                                           ^
./catch.hpp:77:60: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
            NonCopyable& operator=( NonCopyable const& ) = delete;
                                                           ^
./catch.hpp:78:48: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
            NonCopyable& operator=( NonCopyable&& ) = delete;
                                               ^
./catch.hpp:78:55: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
            NonCopyable& operator=( NonCopyable&& ) = delete;
                                                      ^
./catch.hpp:81:26: error: expected ';' at end of declaration list
            NonCopyable() noexcept = default;
                         ^
                         ;

Please suggest, Thanks.

Edit:

After @Tiib suggested to try with g++ -std=c++17 the code got compiled and build. g++ -std=c++11 also did not work. Not understood why.

thevikas
  • 1,618
  • 1
  • 14
  • 31

0 Answers0