diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-12-03 17:11:43 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-12-08 10:21:07 +0100 |
| commit | 0c39051ba80f04b1177833a006f2d442a7170b56 (patch) | |
| tree | 9e657946a061b5b305f9cf75634db7b37e979eb3 /labb8/lib/StanfordCPPLib/startup.cpp | |
| parent | 7b7f6808a7b2db2ed21103767434c1445f7815c2 (diff) | |
| download | tddd86-0c39051ba80f04b1177833a006f2d442a7170b56.tar.gz | |
add initial files l8
Diffstat (limited to 'labb8/lib/StanfordCPPLib/startup.cpp')
| -rwxr-xr-x | labb8/lib/StanfordCPPLib/startup.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/labb8/lib/StanfordCPPLib/startup.cpp b/labb8/lib/StanfordCPPLib/startup.cpp new file mode 100755 index 0000000..d6d3ff8 --- /dev/null +++ b/labb8/lib/StanfordCPPLib/startup.cpp @@ -0,0 +1,34 @@ +/* + * File: startup.cpp + * ----------------- + * This file implements the wrapper for main that allows for + * system initialization and error handling. + */ + +#include <cstdlib> +#include <iostream> +#include "error.h" +using namespace std; + +#if defined (_MSC_VER) && (_MSC_VER >= 1200) +# include <windows.h> +# define MSC_ERROR_FLAGS (MB_OK | MB_ICONSTOP | MB_TOPMOST) +#endif + +/* Global flag word indicating option for main */ + +int _mainFlags; + +int mainWrapper(int argc, char **argv) { + extern int Main(int argc, char **argv); + try { + return Main(argc, argv); + } catch (ErrorException & ex) { + string msg = "Error: " + ex.getMessage(); + cerr << msg << endl; +#ifdef _MSC_VER + MessageBoxA(NULL, msg.c_str(), "Error!", MSC_ERROR_FLAGS); +#endif + return EXIT_FAILURE; + } +} |
