// Runtime check 1: C++ runtime in a GCC-built XEX (static constructor,
// exception, std::regex), reported with guide notifications.
#include <string>
#include <regex>
#include <stdexcept>
#include <cstdio>
#include "xex_runtime.h"
struct StaticInit {
int value;
StaticInit() : value(42) {}
};
static StaticInit g_static;
int main(int, char **) {
std::string result = "GCC XEX ok:";
result += g_static.value == 42 ? " ctor" : " CTOR-FAIL";
try {
throw std::runtime_error("x");
} catch (const std::exception &) {
result += " exc";
} catch (...) {
result += " EXC-WRONG";
}
std::smatch m;
std::string s = "#include foo.lua";
bool re = std::regex_search(s, m, std::regex("#include\\s+([a-z.]+)")) && m[1] == "foo.lua";
result += re ? " regex" : " REGEX-FAIL";
printf("hello: %s\n", result.c_str());
xex_notify("Hello from FAKE-08 XEX (GCC)");
xex_sleep_ms(3000);
xex_notify(result.c_str());
xex_sleep_ms(5000);
return 0;
}