From 0c39051ba80f04b1177833a006f2d442a7170b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Thu, 3 Dec 2020 17:11:43 +0100 Subject: add initial files l8 --- labb8/lib/StanfordCPPLib/private/main.h | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 labb8/lib/StanfordCPPLib/private/main.h (limited to 'labb8/lib/StanfordCPPLib/private/main.h') diff --git a/labb8/lib/StanfordCPPLib/private/main.h b/labb8/lib/StanfordCPPLib/private/main.h new file mode 100755 index 0000000..698a97c --- /dev/null +++ b/labb8/lib/StanfordCPPLib/private/main.h @@ -0,0 +1,58 @@ +/* + * File: main.h + * ------------ + * This file renames the main method in the client's + * program to Main, thereby allowing a custom + * main method in the libraries to take control + * before passing control back to the client program. The main macro + * also defines a function getMainFlags that returns an int whose bits + * indicate which of the various interfaces have been loaded by this + * definition of main. + * + * Note: This file can be loaded more than once and must therefore + * check to see what has already been defined. + */ + +#ifdef main +# undef main +# undef CONSOLE_FLAG +# undef GRAPHICS_FLAG +#else +# define MAIN_USES_CONSOLE (1<<0) +# define MAIN_USES_GRAPHICS (1<<1) +#endif + +#ifdef _console_h +# define CONSOLE_FLAG MAIN_USES_CONSOLE +#else +# define CONSOLE_FLAG 0 +#endif + +#ifdef _gwindow_h +# define GRAPHICS_FLAG MAIN_USES_GRAPHICS +#else +# define GRAPHICS_FLAG 0 +#endif + +#if CONSOLE_FLAG | GRAPHICS_FLAG + +#define main main(int argc, char **argv) { \ + extern int _mainFlags; \ + _mainFlags = GRAPHICS_FLAG + CONSOLE_FLAG; \ + return startupMain(argc, argv); \ + } \ + int Main + +extern int startupMain(int argc, char **argv); + +#else + +#define main main(int argc, char **argv) { \ + extern int _mainFlags; \ + _mainFlags = GRAPHICS_FLAG + CONSOLE_FLAG; \ + return mainWrapper(argc, argv); } \ + int Main + +extern int mainWrapper(int argc, char **argv); + +#endif -- cgit v1.2.1