00001 //---------------------------------------------------------------------------- 00002 /** @file SgInit.cpp 00003 See SgInit.h */ 00004 //---------------------------------------------------------------------------- 00005 00006 #include "SgSystem.h" 00007 #include "SgInit.h" 00008 00009 #include <iostream> 00010 #include "SgException.h" 00011 #include "SgMemCheck.h" 00012 #include "SgProp.h" 00013 00014 using namespace std; 00015 00016 //---------------------------------------------------------------------------- 00017 00018 namespace { 00019 00020 bool s_isSgInitialized = false; 00021 00022 } // namespace 00023 00024 //---------------------------------------------------------------------------- 00025 00026 void SgFini() 00027 { 00028 SgProp::Fini(); 00029 SgMemCheck(); 00030 s_isSgInitialized = false; 00031 } 00032 00033 void SgInitImpl(bool compiledInDebugMode) 00034 { 00035 // Compiling the library and user code with inconsistent definition 00036 // of NDEBUG causes undefined behavoior, since some of the SmartGame 00037 // classes contain additional debugging variables in debug mode, and the 00038 // user code will have different opinions about the size and layout of 00039 // these classes. 00040 // This function must not be inline, it needs to use the setting of 00041 // _DEBUG at the compile-time of the library. 00042 #ifndef NDEBUG 00043 if (! compiledInDebugMode) 00044 { 00045 cerr << 00046 "Incompatible library: SmartGame was compiled " 00047 "without NDEBUG, but main program with\n"; 00048 abort(); 00049 } 00050 #else 00051 if (compiledInDebugMode) 00052 { 00053 cerr << "Incompatible library: SmartGame was compiled " 00054 "with NDEBUG, but main program without\n"; 00055 abort(); 00056 } 00057 #endif 00058 00059 SgProp::Init(); 00060 s_isSgInitialized = true; 00061 } 00062 00063 void SgInitCheck() 00064 { 00065 if (! s_isSgInitialized) 00066 throw SgException("SgInit not called"); 00067 } 00068 00069 //---------------------------------------------------------------------------- 00070