summaryrefslogtreecommitdiffstats
path: root/examples/example-main
diff options
context:
space:
mode:
Diffstat (limited to 'examples/example-main')
-rw-r--r--examples/example-main/main.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/example-main/main.cpp b/examples/example-main/main.cpp
new file mode 100644
index 000000000..46ffc7278
--- /dev/null
+++ b/examples/example-main/main.cpp
@@ -0,0 +1,32 @@
+#include "../stacktrace-windows/common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int exampleMain(int argc, char** argv);
+
+#if defined(_WIN32)
+
+#include <windows.h>
+
+int main(int argc, char** argv)
+{
+ __try
+ {
+ return exampleMain(argc, argv);
+ }
+ __except (exceptionFilter(stdout, GetExceptionInformation()))
+ {
+ ::exit(1);
+ }
+}
+
+#else // defined(_WIN32)
+
+int main(int argc, char** argv)
+{
+ // TODO: Catch exception and print stack trace also on non-Windows platforms.
+ return exampleMain(argc, argv);
+}
+
+#endif