diff --git a/renderdoc/common/common.h b/renderdoc/common/common.h
index 6bff23b5c..b90f06577 100644
--- a/renderdoc/common/common.h
+++ b/renderdoc/common/common.h
@@ -36,20 +36,20 @@
// Utility macros
#ifndef SAFE_DELETE
-#define SAFE_DELETE(p) do { if (p) { delete (p); (p)=NULL; } } while(0)
+#define SAFE_DELETE(p) do { if (p) { delete (p); (p)=NULL; } } while((void)0,0)
#endif
#ifndef SAFE_DELETE_ARRAY
-#define SAFE_DELETE_ARRAY(p) do { if (p) { delete[] (p); (p)=NULL; } } while(0)
+#define SAFE_DELETE_ARRAY(p) do { if (p) { delete[] (p); (p)=NULL; } } while((void)0,0)
#endif
#ifndef SAFE_ADDREF
-#define SAFE_ADDREF(p) do { if (p) { (p)->AddRef(); } } while(0)
+#define SAFE_ADDREF(p) do { if (p) { (p)->AddRef(); } } while((void)0,0)
#endif
#ifndef SAFE_RELEASE
-#define SAFE_RELEASE(p) do { if (p) { (p)->Release(); (p)=NULL; } } while(0)
-#define SAFE_RELEASE_NOCLEAR(p) do { if (p) { (p)->Release(); } } while(0)
+#define SAFE_RELEASE(p) do { if (p) { (p)->Release(); (p)=NULL; } } while((void)0,0)
+#define SAFE_RELEASE_NOCLEAR(p) do { if (p) { (p)->Release(); } } while((void)0,0)
#endif
#ifndef ARRAY_COUNT
@@ -98,15 +98,15 @@ uint32_t CalcNumMips(int Width, int Height, int Depth);
/////////////////////////////////////////////////
// Debugging features
-#define RDCDUMP() do { OSUtility::ForceCrash(); } while(0)
+#define RDCDUMP() do { OSUtility::ForceCrash(); } while((void)0,0)
#if !defined(RELEASE) || defined(FORCE_DEBUGBREAK)
-#define RDCBREAK() do { if(OSUtility::DebuggerPresent()) OS_DEBUG_BREAK(); } while(0)
+#define RDCBREAK() do { if(OSUtility::DebuggerPresent()) OS_DEBUG_BREAK(); } while((void)0,0)
#else
-#define RDCBREAK() do { } while(0)
+#define RDCBREAK() do { } while((void)0,0)
#endif
-#define RDCUNIMPLEMENTED(...) do { rdclog(RDCLog_Warning, "Unimplemented: " __VA_ARGS__); RDCBREAK(); } while(0)
+#define RDCUNIMPLEMENTED(...) do { rdclog(RDCLog_Warning, "Unimplemented: " __VA_ARGS__); RDCBREAK(); } while((void)0,0)
//
// Logging
@@ -124,15 +124,15 @@ enum LogType
};
#if defined(STRIP_LOG)
-#define RDCLOGFILE(fn) do { } while(0)
-#define RDCLOGDELETE() do { } while(0)
+#define RDCLOGFILE(fn) do { } while((void)0,0)
+#define RDCLOGDELETE() do { } while((void)0,0)
-#define RDCDEBUG(...) do { } while(0)
-#define RDCLOG(...) do { } while(0)
-#define RDCWARN(...) do { } while(0)
-#define RDCERR(...) do { } while(0)
-#define RDCFATAL(...) do { RDCDUMP(); exit(0); } while(0)
-#define RDCDUMPMSG(message) do { RDCDUMP(); exit(0); } while(0)
+#define RDCDEBUG(...) do { } while((void)0,0)
+#define RDCLOG(...) do { } while((void)0,0)
+#define RDCWARN(...) do { } while((void)0,0)
+#define RDCERR(...) do { } while((void)0,0)
+#define RDCFATAL(...) do { RDCDUMP(); exit(0); } while((void)0,0)
+#define RDCDUMPMSG(message) do { RDCDUMP(); exit(0); } while((void)0,0)
#else
// perform any operations necessary to flush the log
void rdclog_flush();
@@ -155,20 +155,20 @@ void rdclog_filename(const char *filename);
#if ( !defined(RELEASE) || defined(FORCE_DEBUG_LOGS) ) && !defined(STRIP_DEBUG_LOGS)
#define RDCDEBUG(...) rdclog(RDCLog_Debug, __VA_ARGS__)
#else
-#define RDCDEBUG(...) do { } while(0)
+#define RDCDEBUG(...) do { } while((void)0,0)
#endif
#define RDCLOG(...) rdclog(RDCLog_Comment, __VA_ARGS__)
#define RDCWARN(...) rdclog(RDCLog_Warning, __VA_ARGS__)
#if defined(DEBUGBREAK_ON_ERROR_LOG)
-#define RDCERR(...) do { rdclog(RDCLog_Error, __VA_ARGS__); rdclog_flush(); RDCBREAK(); } while(0)
+#define RDCERR(...) do { rdclog(RDCLog_Error, __VA_ARGS__); rdclog_flush(); RDCBREAK(); } while((void)0,0)
#else
#define RDCERR(...) rdclog(RDCLog_Error, __VA_ARGS__)
#endif
-#define RDCFATAL(...) do { rdclog(RDCLog_Fatal, __VA_ARGS__); rdclog_flush(); RDCDUMP(); exit(0); } while(0)
-#define RDCDUMPMSG(message) do { rdclogprint_int(message); rdclog_flush(); RDCDUMP(); exit(0); } while(0)
+#define RDCFATAL(...) do { rdclog(RDCLog_Fatal, __VA_ARGS__); rdclog_flush(); RDCDUMP(); exit(0); } while((void)0,0)
+#define RDCDUMPMSG(message) do { rdclogprint_int(message); rdclog_flush(); RDCDUMP(); exit(0); } while((void)0,0)
#endif
//
@@ -184,7 +184,7 @@ void rdcassert(const char *msg, const char *file, unsigned int line, const char
#include "custom_assert.h"
#else
-#define RDCASSERTMSG(cond) do { } while(0)
+#define RDCASSERTMSG(cond) do { } while((void)0,0)
#endif
#define RDCASSERT(...) RDCASSERTMSG("", __VA_ARGS__)
@@ -196,7 +196,7 @@ void rdcassert(const char *msg, const char *file, unsigned int line, const char
//
#if defined(STRIP_COMPILE_ASSERTS)
-#define RDCCOMPILE_ASSERT(condition, message) do { } while(0)
+#define RDCCOMPILE_ASSERT(condition, message) do { } while((void)0,0)
#else
#define RDCCOMPILE_ASSERT(condition, message) static_assert(condition, message)
#endif
diff --git a/renderdoc/common/custom_assert.h b/renderdoc/common/custom_assert.h
index a4d339244..9b07f4e72 100644
--- a/renderdoc/common/custom_assert.h
+++ b/renderdoc/common/custom_assert.h
@@ -107,7 +107,7 @@
if(!(RDCASSERT_IFCOND(__VA_ARGS__))) { \
const char custommsg[] = msg; (void)custommsg; \
std::string assertmsg = "'" STRINGIZE(RDCASSERT_GETCOND(__VA_ARGS__)) "' "; \
- if(sizeof(custommsg) > 1) assertmsg += msg " "; \
+ assertmsg += (sizeof(custommsg) > 1) ? msg " " : ""; \
std::string failmsg; \
RDCASSERT_FAILMSG(__VA_ARGS__); \
if(!failmsg.empty()) { failmsg.pop_back(); failmsg.pop_back(); } \
@@ -116,4 +116,4 @@
rdclog_flush(); \
RDCBREAK(); \
}\
- } while(0)
+ } while((void)0,0)
diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h
index 8f32fac3c..c6de005ea 100644
--- a/renderdoc/driver/vulkan/vk_replay.h
+++ b/renderdoc/driver/vulkan/vk_replay.h
@@ -48,7 +48,7 @@
using std::map;
// similar to RDCUNIMPLEMENTED but for things that are hit often so we don't want to fire the debugbreak.
-#define VULKANNOTIMP(...) do { static bool msgprinted = false; if(!msgprinted) RDCDEBUG("Vulkan not implemented - " __VA_ARGS__); msgprinted = true; } while(0)
+#define VULKANNOTIMP(...) do { static bool msgprinted = false; if(!msgprinted) RDCDEBUG("Vulkan not implemented - " __VA_ARGS__); msgprinted = true; } while((void)0,0)
// allows easy disabling of MSAA
#define VULKAN_MESH_VIEW_SAMPLES VK_SAMPLE_COUNT_1_BIT
diff --git a/renderdoc/os/win32/win32_network.cpp b/renderdoc/os/win32/win32_network.cpp
index 0f5b2a66c..e2373719d 100644
--- a/renderdoc/os/win32/win32_network.cpp
+++ b/renderdoc/os/win32/win32_network.cpp
@@ -302,7 +302,12 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
{
fd_set set;
FD_ZERO(&set);
+
+ // macro FD_SET contains the do { } while(0) idiom, which warns
+#pragma warning(push)
+#pragma warning(disable : 4127) // conditional expression is constant
FD_SET(s, &set);
+#pragma warning(pop)
int err = WSAGetLastError();
diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj
index 9fcc16426..8c8b5e3bf 100644
--- a/renderdoc/renderdoc.vcxproj
+++ b/renderdoc/renderdoc.vcxproj
@@ -109,7 +109,7 @@
RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;USE_BREAKPAD;WIN32;RELEASE;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
- /wd4100 /wd4127
+ /wd4100
$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\
false
true
@@ -138,7 +138,7 @@
RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;USE_BREAKPAD;WIN64;WIN32;RELEASE;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
- /wd4100 /wd4127
+ /wd4100
$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\
false
true
@@ -166,7 +166,7 @@
RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
- /wd4100 /wd4127
+ /wd4100
false
EnableFastChecks
$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\
@@ -198,7 +198,7 @@
RENDERDOC_EXPORTS;RENDERDOC_PLATFORM=win32;WIN64;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
- /wd4100 /wd4127
+ /wd4100
false
EnableFastChecks
$(ProjectDir);$(SolutionDir)renderdoc\3rdparty\
diff --git a/renderdoc/serialise/utf8printf.cpp b/renderdoc/serialise/utf8printf.cpp
index 5de00207c..b9b7aa812 100644
--- a/renderdoc/serialise/utf8printf.cpp
+++ b/renderdoc/serialise/utf8printf.cpp
@@ -1136,7 +1136,7 @@ int utf8printf(char *buf, size_t bufsize, const char *fmt, va_list args)
// now parsing an argument specifier
// parse out 0 or more flags
- do
+ for(;;)
{
// if flag is found, continue looping to possibly find more flags
// otherwise break out of this loop
@@ -1157,7 +1157,7 @@ int utf8printf(char *buf, size_t bufsize, const char *fmt, va_list args)
formatter.Flags &= ~PrependSpace;
iter++;
- } while(true);
+ }
// possibly parse a width. Note that width always started with 1-9 as it's decimal,
// and 0 or - would have been picked up as a flag above