| Revision 3018,
1.1 KB
checked in by chris, 21 months ago
(diff) |
|
Log fatal exceptions in main helper using BOX_FATAL instead of printf, to
ensure they get logged in all the right places.
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: MainHelper.h |
|---|
| 5 | // Purpose: Helper stuff for main() programs |
|---|
| 6 | // Created: 2003/08/21 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef MAINHELPER__H |
|---|
| 11 | #define MAINHELPER__H |
|---|
| 12 | |
|---|
| 13 | #include <stdio.h> |
|---|
| 14 | |
|---|
| 15 | #include "BoxException.h" |
|---|
| 16 | #include "Logging.h" |
|---|
| 17 | |
|---|
| 18 | #define MAINHELPER_START \ |
|---|
| 19 | if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ |
|---|
| 20 | { printf(BOX_VERSION "\n"); return 0; } \ |
|---|
| 21 | MEMLEAKFINDER_INIT \ |
|---|
| 22 | MEMLEAKFINDER_START \ |
|---|
| 23 | try { |
|---|
| 24 | #define MAINHELPER_END \ |
|---|
| 25 | } catch(std::exception &e) { \ |
|---|
| 26 | BOX_FATAL(e.what()); \ |
|---|
| 27 | return 1; \ |
|---|
| 28 | } catch(...) { \ |
|---|
| 29 | BOX_FATAL("UNKNOWN"); \ |
|---|
| 30 | return 1; \ |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | #ifdef BOX_MEMORY_LEAK_TESTING |
|---|
| 34 | #define MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT(file, marker) \ |
|---|
| 35 | memleakfinder_setup_exit_report(file, marker); |
|---|
| 36 | #else |
|---|
| 37 | #define MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT(file, marker) |
|---|
| 38 | #endif // BOX_MEMORY_LEAK_TESTING |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | #endif // MAINHELPER__H |
|---|
| 42 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.