summaryrefslogtreecommitdiff
path: root/lib/curl_setup_once.h
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2019-11-30 03:29:36 -0500
committerJay Satiro <raysatiro@yahoo.com>2019-12-01 19:01:02 -0500
commit9c1806ae4684ec5ef1aeb39bb9f15cece1c27256 (patch)
tree519c34c7411ae2afda27b38500f77d456bb8cad9 /lib/curl_setup_once.h
parent0436d4438a9dbfd5dc1364de31281505c7915b25 (diff)
downloadcurl-9c1806ae4684ec5ef1aeb39bb9f15cece1c27256.tar.gz
build: Disable Visual Studio warning "conditional expression is constant"
- Disable warning C4127 "conditional expression is constant" globally in curl_setup.h for when building with Microsoft's compiler. This mainly affects building with the Visual Studio project files found in the projects dir. Prior to this change the cmake and winbuild build systems already disabled 4127 globally for when building with Microsoft's compiler. Also, 4127 was already disabled for all build systems in the limited circumstance of the WHILE_FALSE macro which disabled the warning specifically for while(0). This commit removes the WHILE_FALSE macro and all other cruft in favor of disabling globally in curl_setup. Background: We have various macros that cause 0 or 1 to be evaluated, which would cause warning C4127 in Visual Studio. For example this causes it: #define Curl_resolver_asynch() 1 Full behavior is not clearly defined and inconsistent across versions. However it is documented that since VS 2015 Update 3 Microsoft has addressed this somewhat but not entirely, not warning on while(true) for example. Prior to this change some C4127 warnings occurred when I built with Visual Studio using the generated projects in the projects dir. Closes https://github.com/curl/curl/pull/4658
Diffstat (limited to 'lib/curl_setup_once.h')
-rw-r--r--lib/curl_setup_once.h25
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h
index 413ccea91..9d504cb6e 100644
--- a/lib/curl_setup_once.h
+++ b/lib/curl_setup_once.h
@@ -330,27 +330,6 @@ struct timeval {
#include "curl_ctype.h"
/*
- * Macro WHILE_FALSE may be used to build single-iteration do-while loops,
- * avoiding compiler warnings. Mostly intended for other macro definitions.
- */
-
-#define WHILE_FALSE while(0)
-
-#if defined(_MSC_VER) && !defined(__POCC__)
-# undef WHILE_FALSE
-# if (_MSC_VER < 1500)
-# define WHILE_FALSE while(1, 0)
-# else
-# define WHILE_FALSE \
-__pragma(warning(push)) \
-__pragma(warning(disable:4127)) \
-while(0) \
-__pragma(warning(pop))
-# endif
-#endif
-
-
-/*
* Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
*/
@@ -387,7 +366,7 @@ typedef int sig_atomic_t;
#ifdef DEBUGBUILD
#define DEBUGF(x) x
#else
-#define DEBUGF(x) do { } WHILE_FALSE
+#define DEBUGF(x) do { } while(0)
#endif
@@ -398,7 +377,7 @@ typedef int sig_atomic_t;
#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
#define DEBUGASSERT(x) assert(x)
#else
-#define DEBUGASSERT(x) do { } WHILE_FALSE
+#define DEBUGASSERT(x) do { } while(0)
#endif