summaryrefslogtreecommitdiff
path: root/lib/Main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Main.cc')
-rw-r--r--lib/Main.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Main.cc b/lib/Main.cc
index d5048ba..5555e90 100644
--- a/lib/Main.cc
+++ b/lib/Main.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: Main.cc,v 1.13 2004-12-12 23:01:08 pixel Exp $ */
+/* $Id: Main.cc,v 1.14 2006-11-13 22:00:12 pixel Exp $ */
#ifdef _WIN32
#include <windows.h>
@@ -50,10 +50,28 @@ _open_osfhandle
CreateFileMapping
*/
+#define size_assert(c, s) if (!(sizeof(c) == (s))) { throw GeneralException(String("Sanity Check failure: sizeof(" # c ") == ") + (int) sizeof(c) + " and not " # s " as expected."); }
+#define s_assert(c) if (!(c)) { throw GeneralException("Sanity Check failed: " # c " is false"); }
+
+void Main::sanity_checks() throw (GeneralException) {
+ size_assert(int8, 1);
+ size_assert(int16, 2);
+ size_assert(int32, 4);
+ size_assert(int64, 8);
+ size_assert(Uint8, 1);
+ size_assert(Uint16, 2);
+ size_assert(Uint32, 4);
+ size_assert(Uint64, 8);
+ size_assert(Byte, 1);
+ size_assert(Word, 2);
+ size_assert(DWord, 4);
+}
+
int Main::truemain(Main * Application, int argc, char ** argv, char ** enve) {
int r;
try {
+ sanity_checks();
Application->set_args(argc, argv, enve);
r = Application->startup();
}