Path: blob/main/crates/wizer/examples/cpp/main.cpp
2459 views
#include <stdio.h>1#include <wizer.h>23class Test {4public:5Test() : value(1) {6printf("global constructor (should be the first printed line)\n");7}8~Test() { printf("global destructor (should be the last printed line)\n"); }9int value;10};1112bool initialized = false;13int orig_value = 0;14Test t;1516static void init_func() {17// This should run after the ctor for `t`, and before `main`.18orig_value = t.value;19t.value = 2;20initialized = true;21}2223WIZER_INIT(init_func);2425int main(int argc, char **argv) {26if (!initialized)27init_func();28printf("argc (should not be baked into snapshot): %d\n", argc);29printf("orig_value (should be 1): %d\n", orig_value);30printf("t.value (should be 2): %d\n", t.value);31}323334