diff --git a/SConstruct b/SConstruct index 484a686e..baf1cf1a 100644 --- a/SConstruct +++ b/SConstruct @@ -201,13 +201,15 @@ Help(opts.GenerateHelpText(defenv)) if defenv['TARGET_ARCH'] != 'x86': defenv['UNICODE'] = True +if defenv['DEBUG']: + defenv.Append(CPPDEFINES = ['DEBUG']) + # add prefixes defines if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))]) defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))]) # Need this early for the config header files to be placed in - if defenv['UNICODE']: if defenv['DEBUG']: defenv.Replace(BUILD_PREFIX = 'build/udebug') diff --git a/Source/build.cpp b/Source/build.cpp index f8f6e5c4..bce3fa0b 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -740,7 +740,10 @@ int CEXEBuild::datablock_optimize(int start_offset, int first_int) if (!this->build_optimize_datablock || this_len < (int) sizeof(int)) return start_offset; - MMapBuf *db = (MMapBuf *) cur_datablock; +#ifdef DEBUG + assert(dynamic_cast(cur_datablock)); +#endif + MMapBuf *db = static_cast(cur_datablock); db->setro(TRUE); cached_db_size *db_sizes = (cached_db_size *) this->cur_datablock_cache->get(); @@ -788,7 +791,10 @@ bool CEXEBuild::datablock_finddata(IMMap&mmap, int mmstart, int size, int*ofs) { const int first_int = size; size &= ~ 0x80000000; - MMapBuf *db = (MMapBuf *) cur_datablock; +#ifdef DEBUG + assert(dynamic_cast(cur_datablock)); +#endif + MMapBuf *db = static_cast(cur_datablock); cached_db_size *db_sizes = (cached_db_size *) this->cur_datablock_cache->get(); int db_sizes_num = this->cur_datablock_cache->getlen() / sizeof(cached_db_size); for (int i = 0; i < db_sizes_num; i++) diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index 08032c77..43fcf87f 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -372,7 +372,7 @@ void NSISCALL CleanUp() // Clean up after plug-ins myDelete(state_plugins_dir, DEL_DIR | DEL_RECURSE | DEL_REBOOT); #endif // NSIS_CONFIG_PLUGIN_SUPPORT -#ifdef _DEBUG +#ifdef DEBUG // GlobalFree(g_header); ? #endif } diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index c8279971..76e5a23b 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -303,8 +303,10 @@ static inline int makensismain(int argc, TCHAR **argv) #ifdef _WIN32 signed char outputbom=1; +#ifdef DEBUG assert(CP_ACP == outputenc.GetCodepage()); // Required by CEXEBuild::notify() char* legacy handling. #endif +#endif //~ _WIN32 // Some parameters have to be parsed early so we can initialize stdout and the "host API". while (++argpos < argc && !initialparsefail)