Extending Mys with C++


The Mys C++ API may change at any time and should be avoided if possible.

Extending Mys with C++ is extremly easy and flexible. C-strings, strings prefixed with c, are inserted at the same location in the generated code. Also, all .cpp files found in src/ are compiled and linked with the application.

Start the c-string with header-before-namespace or source-before-namespace to insert the code before the C++ namespace in the generated header and source files respectively.

Using C and C++ libraries is not yet supported.

Below is the contents of src/main.mys found in the embedded_cpp example.

#define FOOBAR 1

#include "cpp/foo.hpp"

func main():
    a = 0
    b = 0

    b = foo::foobar(2);

    print("a + b:", a + b)