diff options
author | Jay Satiro <raysatiro@yahoo.com> | 2019-11-30 03:29:36 -0500 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2019-12-01 19:01:02 -0500 |
commit | 9c1806ae4684ec5ef1aeb39bb9f15cece1c27256 (patch) | |
tree | 519c34c7411ae2afda27b38500f77d456bb8cad9 /src/tool_doswin.c | |
parent | 0436d4438a9dbfd5dc1364de31281505c7915b25 (diff) | |
download | curl-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 'src/tool_doswin.c')
-rw-r--r-- | src/tool_doswin.c | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 779a3cb8f..a64a81633 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -38,33 +38,6 @@ #include "memdebug.h" /* keep this as LAST include */ -/* - * Macros ALWAYS_TRUE and ALWAYS_FALSE are used to avoid compiler warnings. - */ - -#define ALWAYS_TRUE (1) -#define ALWAYS_FALSE (0) - -#if defined(_MSC_VER) && !defined(__POCC__) -# undef ALWAYS_TRUE -# undef ALWAYS_FALSE -# if (_MSC_VER < 1500) -# define ALWAYS_TRUE (0, 1) -# define ALWAYS_FALSE (1, 0) -# else -# define ALWAYS_TRUE \ -__pragma(warning(push)) \ -__pragma(warning(disable:4127)) \ -(1) \ -__pragma(warning(pop)) -# define ALWAYS_FALSE \ -__pragma(warning(push)) \ -__pragma(warning(disable:4127)) \ -(0) \ -__pragma(warning(pop)) -# endif -#endif - #ifdef WIN32 # undef PATH_MAX # define PATH_MAX MAX_PATH @@ -79,9 +52,9 @@ __pragma(warning(pop)) #endif #ifdef WIN32 -# define _use_lfn(f) ALWAYS_TRUE /* long file names always available */ +# define _use_lfn(f) (1) /* long file names always available */ #elif !defined(__DJGPP__) || (__DJGPP__ < 2) /* DJGPP 2.0 has _use_lfn() */ -# define _use_lfn(f) ALWAYS_FALSE /* long file names never available */ +# define _use_lfn(f) (0) /* long file names never available */ #elif defined(__DJGPP__) # include <fcntl.h> /* _use_lfn(f) prototype */ #endif |