catchorg / Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
https://discord.gg/4CWS9zD
Boost Software License 1.0
18.67k stars 3.05k forks source link

Can't cross-compile to Android - 'rethrow_exception' is not a member of 'std' #1219

Open Nadav-Ruskin opened 6 years ago

Nadav-Ruskin commented 6 years ago

Description

I can't cross-compile the header to Android. Tried NDK 13b, 14b, and 16b. Is Android missing an integral part of the library? If so, please add a disclaimer.

[osboxes:/work/build] $ /usr/arm-linux-androideabi/bin/arm-linux-androideabi-g++ -std=gnu++14 -I ../3rdparty/catch/catch/ -o hello_world hello_world.cpp       
In file included from hello_world.cpp:1:0:
catch.hpp: In member function 'std::string Catch::ExceptionTranslatorRegistrar::ExceptionTranslator<T>::translate(std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator, std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator) const':
catch.hpp:1798:7: error: 'rethrow_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());
       ^
catch.hpp:1798:30: error: 'current_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());

Steps to reproduce

1) Install NDK. For comfort, I started out with an image from dockcross. 2) Put catch.hpp in a directory. 3) Make hello_world.cpp in same directory:

#include "catch.hpp"

TEST_CASE("test 1")
{
REQUIRE(1==1);
}

4) Compile, making sure to use the right flags.

[osboxes:/work/build] 1 $ /usr/arm-linux-androideabi/bin/arm-linux-androideabi-g++ -std=gnu++11 -o hello_world hello_world.cpp
In file included from hello_world.cpp:1:0:
catch.hpp: In member function 'std::string Catch::ExceptionTranslatorRegistrar::ExceptionTranslator<T>::translate(std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator, std::vector<std::unique_ptr<const Catch::IExceptionTranslator> >::const_iterator) const':
catch.hpp:1798:7: error: 'rethrow_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());
       ^
catch.hpp:1798:30: error: 'current_exception' is not a member of 'std'
       std::rethrow_exception(std::current_exception());
                              ^

Extra information

horenmar commented 6 years ago

std::rethrow_exception should be a part of conforming C++11 standard library and is required to compile Catch2.

Nadav-Ruskin commented 6 years ago

Should I report a bug here?

horenmar commented 6 years ago

Probably.

In the meantime, you might want to try Catch Classic in the Catch1.x branch, it still supports C++98.

Nadav-Ruskin commented 6 years ago

Thank you for the suggestion. I'll see if applicable.

Nadav-Ruskin commented 6 years ago

OK, this is a non-bug. https://github.com/android-ndk/ndk/issues/648 solved it. Apparently NDK has to use --stl libc++ for proper C++11 support.

Manu343726 commented 6 years ago

FYI I have reproduced the same error using a gcc5 docker image with a conan cross compiling toolchain for armv7 (This image, which is based on the conan docker image for gcc5 on armv7), using single-header catch2 v2.0.1