0

I think I need some human input here :) I have a simple CPP code:

#include <stdexcept>

#include <emscripten/bind.h>

using namespace emscripten;

double add(double a, double b) 
{
    if(a>5)
        throw std::runtime_error("big a");
    return a+b;
}

EMSCRIPTEN_BINDINGS(my_module) {
    function("add", &add);
}

I compile this simple example with:

emcc -lembind -o quick_example.js quick_example.cpp -fexceptions -sDISABLE_EXCEPTION_CATCHING=0 -O2

When I catch the error in JavaScript, it prints out weird numbers instead of the error message. I can only see the error message when not using any level of optimization. What am I missing here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.