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