emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.37k stars 3.25k forks source link

Catch2 Error: A type specifier is required for all declarations #21865

Open SaraBaradaran opened 2 months ago

SaraBaradaran commented 2 months ago

I tried to build magic_enum in WebAssembly using Emscripten. However, it raised an error related to Catch2. I'm not sure what the problem is. magic_enum can be compiled to x86-64 using the same version of Clang that Emscripten 3.1.54 uses.

Emscripten version 3.1.54

This is the error message I received when compiling magic_enum:

/home/magic_enum/test/3rdparty/Catch2/include/catch2/catch.hpp:10754:28: error: a type specifier is required for all declarations
10754 |     FatalConditionHandler::engage_platform() {}

You can reproduce the error using the commands below:

git clone https://github.com/Neargye/magic_enum --recursive
cd magic_enum
mkdir build
cd build
emcmake cmake -DMAGIC_ENUM_OPT_BUILD_TESTS=ON ..
emmake make
sbc100 commented 2 months ago

I imagine what is happening is that those lines around line 10754 are not very well tested and are not being compiled on the native compile because CATCH_CONFIG_POSIX_SIGNALS is being set:

#if !defined( CATCH_CONFIG_WINDOWS_SEH ) && !defined( CATCH_CONFIG_POSIX_SIGNALS )

namespace Catch {                                                                

    // If neither SEH nor signal handling is required, the handler impls            
    // do not have to do anything, and can be empty.                                
    FatalConditionHandler::engage_platform() {}                                  
    FatalConditionHandler::disengage_platform() {}                               
    FatalConditionHandler::FatalConditionHandler() = default;                    
    FatalConditionHandler::~FatalConditionHandler() = default;                   

} // end namespace Catch                                                         

#endif // !CATCH_CONFIG_WINDOWS_SEH && !CATCH_CONFIG_POSIX_SIGNALS  

Those first two lines there looks like they are probably not valid and should have void at the start.