diff --git a/source/lib/cache_adt.h b/source/lib/cache_adt.h index 27d73f0f25..2d61051969 100644 --- a/source/lib/cache_adt.h +++ b/source/lib/cache_adt.h @@ -618,7 +618,7 @@ template struct CacheEntry { size = size_; cost = cost_; - credit = cost; + credit = (float)cost; // else divider will fail debug_assert(size != 0); diff --git a/source/lib/code_annotation.h b/source/lib/code_annotation.h index 62fd77409c..cfabeb6c06 100644 --- a/source/lib/code_annotation.h +++ b/source/lib/code_annotation.h @@ -127,7 +127,7 @@ switch(x % 2) * * @param expression that is expected to evaluate to non-zero at compile-time. **/ -#define cassert(expr) typedef detail::static_assert_<(expr)>::type UID__; +#define cassert(expr) typedef detail::static_assert_<(expr)>::type UID__ namespace detail { template struct static_assert_; @@ -170,4 +170,11 @@ namespace noncopyable_ // protection from unintended ADL typedef noncopyable_::noncopyable noncopyable; +// this form avoids ICC 11 W4 warnings about non-virtual dtors and +// suppression of the copy assignment operator. +#define NONCOPYABLE(className)\ +private:\ + className(const className&);\ + const className& operator=(const className&) + #endif // #ifndef INCLUDED_CODE_ANNOTATION diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index cb867b3dbe..b0a681fb92 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -47,7 +47,7 @@ wchar_t* debug_log_pos = debug_log; // write to memory buffer (fast) void debug_wprintf_mem(const wchar_t* fmt, ...) { - const ssize_t charsLeft = (ssize_t)LOG_CHARS - (debug_log_pos-debug_log); + const ssize_t charsLeft = (ssize_t)(LOG_CHARS - (debug_log_pos-debug_log)); debug_assert(charsLeft >= 0); // potentially not enough room for the new string; throw away the @@ -505,3 +505,4 @@ ErrorReaction debug_OnAssertionFailure(const char* expr, u8* suppress, const cha } + diff --git a/source/lib/fat_time.cpp b/source/lib/fat_time.cpp index d92c1af8fb..e01ba19bfe 100644 --- a/source/lib/fat_time.cpp +++ b/source/lib/fat_time.cpp @@ -45,14 +45,14 @@ u32 FAT_from_time_t(time_t time) struct tm* t = localtime(&time); u16 fat_time = 0; - fat_time |= (t->tm_sec/2); // 5 - fat_time |= (t->tm_min) << 5; // 6 - fat_time |= (t->tm_hour) << 11; // 5 + fat_time |= u16(t->tm_sec/2); // 5 + fat_time |= u16(t->tm_min) << 5; // 6 + fat_time |= u16(t->tm_hour) << 11; // 5 u16 fat_date = 0; - fat_date |= (t->tm_mday); // 5 - fat_date |= (t->tm_mon+1) << 5; // 4 - fat_date |= (t->tm_year-80) << 9; // 7 + fat_date |= u16(t->tm_mday); // 5 + fat_date |= u16(t->tm_mon+1) << 5; // 4 + fat_date |= u16(t->tm_year-80) << 9; // 7 u32 fat_timedate = u32_from_u16(fat_date, fat_time); return fat_timedate; diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index 4345b1e9e8..7702eab61f 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -536,7 +536,7 @@ public: const Path pathname = m_file->Pathname(); m_file.reset(); - m_fileSize += cd_size+sizeof(ECDR); + m_fileSize += off_t(cd_size+sizeof(ECDR)); truncate(pathname.external_directory_string().c_str(), m_fileSize); } diff --git a/source/lib/file/common/trace.cpp b/source/lib/file/common/trace.cpp index 6ef0bc2033..6675eda56f 100644 --- a/source/lib/file/common/trace.cpp +++ b/source/lib/file/common/trace.cpp @@ -23,7 +23,7 @@ //----------------------------------------------------------------------------- TraceEntry::TraceEntry(EAction action, const char* pathname, size_t size) -: m_timestamp(timer_Time()) +: m_timestamp((float)timer_Time()) , m_action(action) , m_pathname(strdup(pathname)) , m_size(size) @@ -52,7 +52,7 @@ TraceEntry::~TraceEntry() void TraceEntry::EncodeAsText(char* text, size_t maxTextChars) const { - const char action = m_action; + const char action = (char)m_action; sprintf_s(text, maxTextChars, "%#010f: %c \"%s\" %d\n", m_timestamp, action, m_pathname, m_size); } diff --git a/source/lib/file/common/trace.h b/source/lib/file/common/trace.h index 57acdad405..f2c8de9aa5 100644 --- a/source/lib/file/common/trace.h +++ b/source/lib/file/common/trace.h @@ -26,7 +26,7 @@ public: enum EAction { Load = 'L', - Store = 'S', + Store = 'S' }; TraceEntry(EAction action, const char* pathname, size_t size); diff --git a/source/lib/file/file_system_util.cpp b/source/lib/file/file_system_util.cpp index 81653349da..47565c44d3 100644 --- a/source/lib/file/file_system_util.cpp +++ b/source/lib/file/file_system_util.cpp @@ -63,9 +63,9 @@ void fs_SortDirectories(DirectoryNames& directories) } -LibError fs_ForEachFile(const PIVFS& fs, const VfsPath& path, FileCallback cb, uintptr_t cbData, const char* pattern, size_t flags) +LibError fs_ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, uintptr_t cbData, const char* pattern, size_t flags) { - debug_assert(vfs_path_IsDirectory(path)); + debug_assert(vfs_path_IsDirectory(startPath)); // (declare here to avoid reallocations) FileInfos files; DirectoryNames subdirectoryNames; @@ -73,7 +73,7 @@ LibError fs_ForEachFile(const PIVFS& fs, const VfsPath& path, FileCallback cb, u // (a FIFO queue is more efficient than recursion because it uses less // stack space and avoids seeks due to breadth-first traversal.) std::queue pendingDirectories; - pendingDirectories.push(path); + pendingDirectories.push(startPath); while(!pendingDirectories.empty()) { const VfsPath& path = pendingDirectories.front(); diff --git a/source/lib/file/io/block_cache.cpp b/source/lib/file/io/block_cache.cpp index e0e803689d..d648428cd5 100644 --- a/source/lib/file/io/block_cache.cpp +++ b/source/lib/file/io/block_cache.cpp @@ -31,8 +31,8 @@ BlockId::BlockId(const Path& pathname, off_t ofs) m_id = fnv_hash64(pathname.string().c_str(), pathname.string().length()); const size_t indexBits = 16; m_id <<= indexBits; - const off_t blockIndex = ofs / BLOCK_SIZE; - debug_assert(blockIndex < off_t(1ul << indexBits)); + const off_t blockIndex = off_t(ofs / BLOCK_SIZE); + debug_assert(blockIndex < off_t(1) << indexBits); m_id |= blockIndex; } diff --git a/source/lib/file/io/io.cpp b/source/lib/file/io/io.cpp index bd06f32411..65e89d5d8e 100644 --- a/source/lib/file/io/io.cpp +++ b/source/lib/file/io/io.cpp @@ -198,8 +198,9 @@ BlockCache BlockIo::s_blockCache; // IoSplitter //----------------------------------------------------------------------------- -class IoSplitter : noncopyable +class IoSplitter { + NONCOPYABLE(IoSplitter); public: IoSplitter(off_t ofs, u8* alignedBuf, off_t size) : m_ofs(ofs), m_alignedBuf(alignedBuf), m_size(size) diff --git a/source/lib/file/io/write_buffer.h b/source/lib/file/io/write_buffer.h index c036a2bccf..8628735d67 100644 --- a/source/lib/file/io/write_buffer.h +++ b/source/lib/file/io/write_buffer.h @@ -29,8 +29,9 @@ private: }; -class UnalignedWriter : public noncopyable +class UnalignedWriter { + NONCOPYABLE(UnalignedWriter); public: UnalignedWriter(const PIFile& file, off_t ofs); ~UnalignedWriter(); diff --git a/source/lib/file/vfs/vfs_populate.cpp b/source/lib/file/vfs/vfs_populate.cpp index 165692b4c5..40c26c189a 100644 --- a/source/lib/file/vfs/vfs_populate.cpp +++ b/source/lib/file/vfs/vfs_populate.cpp @@ -25,8 +25,9 @@ static size_t s_numArchivedFiles; // helper class that allows breaking up the logic into sub-functions without // always having to pass directory/realDirectory as parameters. -class PopulateHelper : noncopyable +class PopulateHelper { + NONCOPYABLE(PopulateHelper); public: PopulateHelper(VfsDirectory* directory, const PRealDirectory& realDirectory) : m_directory(directory), m_realDirectory(realDirectory) diff --git a/source/lib/frequency_filter.cpp b/source/lib/frequency_filter.cpp index e7b945d455..7930b06ad1 100644 --- a/source/lib/frequency_filter.cpp +++ b/source/lib/frequency_filter.cpp @@ -7,8 +7,9 @@ static const double sensitivity = 0.10; /** * variable-width window for frequency determination **/ -class FrequencyEstimator : boost::noncopyable +class FrequencyEstimator { + NONCOPYABLE(FrequencyEstimator); public: FrequencyEstimator(double resolution) : m_minDeltaTime(4.0 * resolution) // chosen to reduce error but still yield rapid updates. @@ -165,10 +166,11 @@ private: class FrequencyFilter : public IFrequencyFilter { + NONCOPYABLE(FrequencyFilter); public: FrequencyFilter(double resolution, double expectedFrequency) : m_controller(expectedFrequency), m_frequencyEstimator(resolution), m_iirFilter(sensitivity, expectedFrequency) - , m_stableFrequency(expectedFrequency), m_smoothedFrequency(expectedFrequency) + , m_stableFrequency((int)expectedFrequency), m_smoothedFrequency(expectedFrequency) { } diff --git a/source/lib/lib_errors.h b/source/lib/lib_errors.h index eb130d814f..8117432c91 100644 --- a/source/lib/lib_errors.h +++ b/source/lib/lib_errors.h @@ -169,7 +169,7 @@ extern int error_AddAssociation(LibErrorAssociation*); // Invoke this at file or function scope. #define ERROR_ASSOCIATE(err, description, errno_equivalent)\ static LibErrorAssociation UID__ = { err, description, errno_equivalent };\ - static int UID2__ = error_AddAssociation(&UID__); + static int UID2__ = error_AddAssociation(&UID__) /** diff --git a/source/lib/path_util.cpp b/source/lib/path_util.cpp index 2f02b554f7..f59d1ff9a1 100644 --- a/source/lib/path_util.cpp +++ b/source/lib/path_util.cpp @@ -37,7 +37,7 @@ bool path_is_dir_sep(char c) return false; } -bool path_is_dir_sepw(wchar_t c) +static bool path_is_dir_sepw(wchar_t c) { // note: ideally path strings would only contain '/' or even SYS_DIR_SEP. // however, windows-specific code (e.g. the sound driver detection) @@ -73,7 +73,7 @@ bool path_is_subpath(const char* s1, const char* s2) if(strlen(s1) > strlen(s2)) std::swap(s1, s2); - int c1 = 0, last_c1, c2; + char c1 = 0, last_c1, c2; for(;;) { last_c1 = c1; diff --git a/source/lib/precompiled.h b/source/lib/precompiled.h index 5b3824ff0c..9cf3235dbf 100644 --- a/source/lib/precompiled.h +++ b/source/lib/precompiled.h @@ -32,6 +32,10 @@ # pragma warning(disable:6246) // local declaration hides declaration of the same name in outer scope # endif # if ICC_VERSION +# pragma warning(disable:383) // value copied to temporary, reference to temporary used +# pragma warning(disable:981) // operands are evaluted in unspecified order +# pragma warning(disable:1418) // external function definition with no prior declaration (raised for all non-static function templates) +# pragma warning(disable:1572) // floating-point equality and inequality comparisons are unreliable # pragma warning(disable:1786) // function is deprecated (disabling 4996 isn't sufficient) # pragma warning(disable:1684) // conversion from pointer to same-sized integral type # endif @@ -62,7 +66,6 @@ #ifndef LIB_STATIC_LINK # define BOOST_ALL_DYN_LINK #endif -#include // noncopyable // the following boost libraries have been included in TR1 and are // thus deemed usable: #include diff --git a/source/lib/sysdep/acpi.cpp b/source/lib/sysdep/acpi.cpp index 957068b1f2..f1006dfd64 100644 --- a/source/lib/sysdep/acpi.cpp +++ b/source/lib/sysdep/acpi.cpp @@ -207,7 +207,7 @@ static bool VerifyTable(const AcpiTable* table, const char* signature = 0) // no specific signature is called for; just make sure it's 4 letters else { - for(int i = 0; i < 4; i++) + for(size_t i = 0; i < 4; i++) { if(!isalpha(table->signature[i])) return false; @@ -255,7 +255,7 @@ struct RSDT // avoid std::map et al. because we may be called before _cinit static const AcpiTable** tables; -static int numTables; +static size_t numTables; static bool LatchAllTables() { @@ -269,7 +269,7 @@ static bool LatchAllTables() numTables = (rsdt->header.size - sizeof(AcpiTable)) / sizeof(rsdt->tables[0]); debug_assert(numTables > 0); tables = new const AcpiTable*[numTables]; - for(int i = 0; i < numTables; i++) + for(size_t i = 0; i < numTables; i++) tables[i] = GetTable(rsdt->tables[i]); DeallocateTable(rsdt); @@ -281,7 +281,7 @@ static void FreeAllTables() { if(tables) { - for(int i = 0; i < numTables; i++) + for(size_t i = 0; i < numTables; i++) DeallocateTable(tables[i]); delete[] tables; } @@ -291,7 +291,7 @@ static void FreeAllTables() const AcpiTable* acpi_GetTable(const char* signature) { // (typically only a few tables, linear search is OK) - for(int i = 0; i < numTables; i++) + for(size_t i = 0; i < numTables; i++) { const AcpiTable* table = tables[i]; if(!table) diff --git a/source/lib/sysdep/acpi.h b/source/lib/sysdep/acpi.h index d60cb3e97c..427394d49b 100644 --- a/source/lib/sysdep/acpi.h +++ b/source/lib/sysdep/acpi.h @@ -33,7 +33,7 @@ enum AcpiAddressSpace ACPI_AS_MEMORY = 0, ACPI_AS_IO = 1, ACPI_AS_PCI_CONFIG = 2, - ACPI_AS_SMBUS = 4, + ACPI_AS_SMBUS = 4 }; // address of a struct or register diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.h b/source/lib/sysdep/arch/x86_x64/x86_x64.h index a4f24dcbd1..3cde493cbb 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.h +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.h @@ -47,7 +47,7 @@ enum x86_x64_Vendors { X86_X64_VENDOR_UNKNOWN, X86_X64_VENDOR_INTEL, - X86_X64_VENDOR_AMD, + X86_X64_VENDOR_AMD }; LIB_API x86_x64_Vendors x86_x64_Vendor(); diff --git a/source/lib/sysdep/dir_watch.h b/source/lib/sysdep/dir_watch.h index 10f23a900c..996f1386c6 100644 --- a/source/lib/sysdep/dir_watch.h +++ b/source/lib/sysdep/dir_watch.h @@ -40,7 +40,7 @@ public: { Created, Deleted, - Changed, + Changed }; // (default ctor is required because DirWatchNotification is returned diff --git a/source/lib/sysdep/gfx.cpp b/source/lib/sysdep/gfx.cpp index f6bc1a5ebe..41f77c5a00 100644 --- a/source/lib/sysdep/gfx.cpp +++ b/source/lib/sysdep/gfx.cpp @@ -12,6 +12,7 @@ #include "gfx.h" #include "lib/external_libraries/sdl.h" +#include "lib/ogl.h" char gfx_card[GFX_CARD_LEN] = ""; @@ -20,8 +21,6 @@ char gfx_drv_ver[GFX_DRV_VER_LEN] = ""; int gfx_mem = -1; // [MiB]; approximate -extern LibError ogl_get_gfx_info(); - // detect graphics card and set the above information. void gfx_detect() { diff --git a/source/lib/sysdep/os/win/wdbg_heap.cpp b/source/lib/sysdep/os/win/wdbg_heap.cpp index 3fb1b3a476..e52025c167 100644 --- a/source/lib/sysdep/os/win/wdbg_heap.cpp +++ b/source/lib/sysdep/os/win/wdbg_heap.cpp @@ -18,6 +18,7 @@ WINIT_REGISTER_LATE_SHUTDOWN2(wdbg_heap_Shutdown); // last - no leaks are detect void wdbg_heap_Enable(bool enable) { +#ifdef _DEBUG // (avoid "expression has no effect" warning in release builds) int flags = 0; if(enable) { @@ -34,6 +35,9 @@ void wdbg_heap_Enable(bool enable) // the normal build process as well as when debugging the test .exe _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); +#else + UNUSED2(enable); +#endif } diff --git a/source/lib/sysdep/os/win/wdbg_sym.cpp b/source/lib/sysdep/os/win/wdbg_sym.cpp index a9bcdf8dfa..e21f3768ac 100644 --- a/source/lib/sysdep/os/win/wdbg_sym.cpp +++ b/source/lib/sysdep/os/win/wdbg_sym.cpp @@ -577,7 +577,7 @@ static LibError out_check_limit() //---------------------------------------------------------------------------- -#define INDENT STMT(for(size_t i = 0; i <= state.level; i++) out(L" ");) +#define INDENT STMT(for(size_t i__ = 0; i__ <= state.level; i__++) out(L" ");) #define UNINDENT STMT(out_erase((state.level+1)*4);) diff --git a/source/lib/sysdep/os/win/whrt/qpc.cpp b/source/lib/sysdep/os/win/whrt/qpc.cpp index 0ce9c56156..0a193c7522 100644 --- a/source/lib/sysdep/os/win/whrt/qpc.cpp +++ b/source/lib/sysdep/os/win/whrt/qpc.cpp @@ -80,10 +80,10 @@ public: // used on MP HAL systems and can be detected by comparing QPF with the // CPU clock. we consider it unsafe unless the user promises (via // command line) that it's patched and thus reliable on their system. - bool usesTsc = IsSimilarMagnitude(m_frequency, os_cpu_ClockFrequency()); + bool usesTsc = IsSimilarMagnitude((double)m_frequency, os_cpu_ClockFrequency()); // unconfirmed reports indicate QPC sometimes uses 1/3 of the // CPU clock frequency, so check that as well. - usesTsc |= IsSimilarMagnitude(m_frequency, os_cpu_ClockFrequency()/3); + usesTsc |= IsSimilarMagnitude((double)m_frequency, os_cpu_ClockFrequency()/3); if(usesTsc) { const bool isTscSafe = wutil_HasCommandLineArgument("-wQpcTscSafe"); diff --git a/source/lib/sysdep/os/win/winit.h b/source/lib/sysdep/os/win/winit.h index 49dbaf9a22..7774ca025b 100644 --- a/source/lib/sysdep/os/win/winit.h +++ b/source/lib/sysdep/os/win/winit.h @@ -117,29 +117,29 @@ Several methods of module init are possible: (see Large Scale C++ Design) // very early init; must not fail, since error handling code *crashes* // if called before these have completed. -#define WINIT_REGISTER_CRITICAL_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_CRITICAL_INIT(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I0")) LibError (*p##func)(void) = func // meant for modules with dependents but whose init is complicated and may // raise error/warning messages (=> can't go in WINIT_REGISTER_CRITICAL_INIT) -#define WINIT_REGISTER_EARLY_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_EARLY_INIT(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I1")) LibError (*p##func)(void) = func // available for dependents of WINIT_REGISTER_EARLY_INIT-modules that // must still come before WINIT_REGISTER_MAIN_INIT. -#define WINIT_REGISTER_EARLY_INIT2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I2")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_EARLY_INIT2(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I2")) LibError (*p##func)(void) = func // most modules will go here unless they are often used or // have many dependents. -#define WINIT_REGISTER_MAIN_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_MAIN_INIT(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I6")) LibError (*p##func)(void) = func // available for any modules that may need to come after // WINIT_REGISTER_MAIN_INIT (unlikely) -#define WINIT_REGISTER_LATE_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_LATE_INIT(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I7")) LibError (*p##func)(void) = func -#define WINIT_REGISTER_EARLY_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) -#define WINIT_REGISTER_EARLY_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) -#define WINIT_REGISTER_MAIN_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) -#define WINIT_REGISTER_LATE_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) -#define WINIT_REGISTER_LATE_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S8")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_EARLY_SHUTDOWN(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S0")) LibError (*p##func)(void) = func +#define WINIT_REGISTER_EARLY_SHUTDOWN2(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S1")) LibError (*p##func)(void) = func +#define WINIT_REGISTER_MAIN_SHUTDOWN(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S6")) LibError (*p##func)(void) = func +#define WINIT_REGISTER_LATE_SHUTDOWN(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S7")) LibError (*p##func)(void) = func +#define WINIT_REGISTER_LATE_SHUTDOWN2(func) __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S8")) LibError (*p##func)(void) = func //----------------------------------------------------------------------------- diff --git a/source/lib/sysdep/os/win/wnuma.cpp b/source/lib/sysdep/os/win/wnuma.cpp index 2c78216b65..4b93c1e99d 100644 --- a/source/lib/sysdep/os/win/wnuma.cpp +++ b/source/lib/sysdep/os/win/wnuma.cpp @@ -46,14 +46,18 @@ static void FillNodesProcessorMask(uintptr_t* nodesProcessorMask) if(pGetNumaNodeProcessorMask) { DWORD_PTR processAffinity, systemAffinity; - const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &processAffinity, &systemAffinity); - debug_assert(ok); + { + const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &processAffinity, &systemAffinity); + debug_assert(ok); + } for(size_t node = 0; node < numa_NumNodes(); node++) { ULONGLONG affinity; - const BOOL ok = pGetNumaNodeProcessorMask((UCHAR)node, &affinity); - debug_assert(ok); + { + const BOOL ok = pGetNumaNodeProcessorMask((UCHAR)node, &affinity); + debug_assert(ok); + } const uintptr_t processorMask = wcpu_ProcessorMaskFromAffinity(processAffinity, (DWORD_PTR)affinity); nodesProcessorMask[node] = processorMask; } diff --git a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp index 66bb1f8be7..93955df164 100644 --- a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -145,7 +145,7 @@ int access(const char* path, int mode) } -#if !HAVE_MKDIR +#ifndef HAVE_MKDIR int mkdir(const char* path, mode_t UNUSED(mode)) { if(!CreateDirectory(path, (LPSECURITY_ATTRIBUTES)NULL)) @@ -155,7 +155,7 @@ int mkdir(const char* path, mode_t UNUSED(mode)) return 0; } -#endif // #if !HAVE_MKDIR +#endif int rmdir(const char* path) @@ -341,7 +341,7 @@ int readdir_stat_np(DIR* d_, struct stat* s) memset(s, 0, sizeof(*s)); s->st_size = (off_t)u64_from_u32(d->fd.nFileSizeHigh, d->fd.nFileSizeLow); - s->st_mode = (d->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG; + s->st_mode = (unsigned short)((d->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG); s->st_mtime = filetime_to_time_t(&d->fd.ftLastWriteTime); return 0; } diff --git a/source/lib/sysdep/os/win/wsdl.cpp b/source/lib/sysdep/os/win/wsdl.cpp index c7a829a7c8..4f62210f30 100644 --- a/source/lib/sysdep/os/win/wsdl.cpp +++ b/source/lib/sysdep/os/win/wsdl.cpp @@ -105,7 +105,7 @@ private: if(gamma == 1.0f) { for(u16 i = 0; i < 256; i++) - ramp[i] = (i << 8); + ramp[i] = u16(i << 8); return; } @@ -411,7 +411,7 @@ static inline void queue_active_event(SdlActivationType type, size_t changed_app SDL_Event ev; ev.type = SDL_ACTIVEEVENT; ev.active.state = (u8)changed_app_state; - ev.active.gain = (type == GAIN)? 1 : 0; + ev.active.gain = (u8)((type == GAIN)? 1 : 0); queue_event(ev); } @@ -421,9 +421,9 @@ static inline void queue_active_event(SdlActivationType type, size_t changed_app // they control the main loop. static Uint8 app_state; -static void active_change_state(SdlActivationType type, size_t changed_app_state) +static void active_change_state(SdlActivationType type, Uint8 changed_app_state) { - size_t old_app_state = app_state; + Uint8 old_app_state = app_state; if(type == GAIN) app_state |= changed_app_state; @@ -440,7 +440,7 @@ static void reset_all_keys(); static LRESULT OnActivate(HWND hWnd, UINT state, HWND UNUSED(hWndActDeact), BOOL fMinimized) { SdlActivationType type; - size_t changed_app_state; + Uint8 changed_app_state; // went active and not minimized if(state != WA_INACTIVE && !fMinimized) @@ -939,11 +939,13 @@ static LRESULT OnDestroy(HWND hWnd) queue_quit_event(); PostQuitMessage(0); +#ifdef _DEBUG // see http://www.adrianmccarthy.com/blog/?p=51 // with WM_QUIT in the message queue, MessageBox will immediately // return IDABORT. to ensure any subsequent CRT error reports are // at least somewhat visible, we redirect them to debug output. _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); +#endif return 0; } diff --git a/source/lib/sysdep/os/win/wsysdep.cpp b/source/lib/sysdep/os/win/wsysdep.cpp index 9e33465032..622b9f3458 100644 --- a/source/lib/sysdep/os/win/wsysdep.cpp +++ b/source/lib/sysdep/os/win/wsysdep.cpp @@ -300,15 +300,12 @@ LibError sys_error_description_r(int user_err, char* buf, size_t max_chars) void sys_get_module_filename(void* addr, wchar_t* path, size_t max_chars) { path[0] = '\0'; // in case either API call below fails - wchar_t* module_filename = path; MEMORY_BASIC_INFORMATION mbi; if(VirtualQuery(addr, &mbi, sizeof(mbi))) { HMODULE hModule = (HMODULE)mbi.AllocationBase; - if(GetModuleFileNameW(hModule, path, (DWORD)max_chars)) - module_filename = wcsrchr(path, '\\')+1; - // note: GetModuleFileName returns full path => a '\\' exists + GetModuleFileNameW(hModule, path, (DWORD)max_chars); } } diff --git a/source/lib/sysdep/os/win/wutil.cpp b/source/lib/sysdep/os/win/wutil.cpp index b775c514a4..9ae5d7bf20 100644 --- a/source/lib/sysdep/os/win/wutil.cpp +++ b/source/lib/sysdep/os/win/wutil.cpp @@ -420,7 +420,7 @@ WinScopedDisableWow64Redirection::~WinScopedDisableWow64Redirection() HMODULE wutil_LibModuleHandle; -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID reserved) +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD UNUSED(reason), LPVOID UNUSED(reserved)) { DisableThreadLibraryCalls(hInstance); wutil_LibModuleHandle = hInstance; diff --git a/source/lib/timer.h b/source/lib/timer.h index 22663fab31..a2ff7d7c66 100644 --- a/source/lib/timer.h +++ b/source/lib/timer.h @@ -37,8 +37,9 @@ LIB_API double timer_Resolution(void); // scope timing /// used by TIMER -class ScopeTimer : noncopyable +class ScopeTimer { + NONCOPYABLE(ScopeTimer); public: ScopeTimer(const char* description) : m_t0(timer_Time()), m_description(description) @@ -176,7 +177,6 @@ public: ss << m_ticks*scale; ss << unit; return ss.str(); - } double ToSeconds() const @@ -228,7 +228,8 @@ public: std::stringstream ss; ss << m_seconds*scale; ss << unit; - return ss.str(); } + return ss.str(); + } double ToSeconds() const { @@ -296,6 +297,7 @@ LIB_API void timer_DisplayClientTotals(); /// used by TIMER_ACCRUE class ScopeTimerAccrue { + NONCOPYABLE(ScopeTimerAccrue); public: ScopeTimerAccrue(TimerClient* tc) : m_tc(tc)