#include #include #include #include #include #include void load_caml(char *argv[]) { caml_main(argv); } void print_closure(const std::string &closure_name) { value * closure_f = caml_named_value(closure_name.c_str()); if (closure_f == nullptr) { std::cerr << "ERROR: Unreachable closure " << closure_name << "\n"; return; } const char *str = String_val(caml_callback(*closure_f, Val_unit)); std::cout << closure_name << ": " << str << "\n"; } int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); load_caml(argv); std::cout << "test std::cout" << "\n"; std::cerr << "test std::cerr" << "\n"; print_closure("name"); print_closure("version"); return app.exec(); }