Browse Source

Disable visual Studio warning for DEBUG build

bel2125 7 năm trước cách đây
mục cha
commit
573821ce37
2 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 2 2
      src/civetweb.c
  2. 7 0
      src/main.c

+ 2 - 2
src/civetweb.c

@@ -3096,8 +3096,8 @@ static char *
 mg_strndup_ctx(const char *ptr, size_t len, struct mg_context *ctx)
 mg_strndup_ctx(const char *ptr, size_t len, struct mg_context *ctx)
 {
 {
 	char *p;
 	char *p;
-    (void)ctx; /* Avoid Visual Studio warning if USE_SERVER_STATS is not
-                * defined */
+	(void)ctx; /* Avoid Visual Studio warning if USE_SERVER_STATS is not
+	            * defined */
 
 
 	if ((p = (char *)mg_malloc_ctx(len + 1, ctx)) != NULL) {
 	if ((p = (char *)mg_malloc_ctx(len + 1, ctx)) != NULL) {
 		mg_strlcpy(p, ptr, len + 1);
 		mg_strlcpy(p, ptr, len + 1);

+ 7 - 0
src/main.c

@@ -136,6 +136,12 @@ extern char *_getcwd(char *buf, size_t size);
 
 
 #if !defined(DEBUG_ASSERT)
 #if !defined(DEBUG_ASSERT)
 #if defined(DEBUG)
 #if defined(DEBUG)
+
+#if defined(_MSC_VER)
+/* DEBUG_ASSERT has some const conditions */
+#pragma warning(disable : 4127)
+#endif
+
 #define DEBUG_ASSERT(cond)                                                     \
 #define DEBUG_ASSERT(cond)                                                     \
 	do {                                                                       \
 	do {                                                                       \
 		if (!(cond)) {                                                         \
 		if (!(cond)) {                                                         \
@@ -143,6 +149,7 @@ extern char *_getcwd(char *buf, size_t size);
 			exit(2); /* Exit with error */                                     \
 			exit(2); /* Exit with error */                                     \
 		}                                                                      \
 		}                                                                      \
 	} while (0)
 	} while (0)
+
 #else
 #else
 #define DEBUG_ASSERT(cond)                                                     \
 #define DEBUG_ASSERT(cond)                                                     \
 	do {                                                                       \
 	do {                                                                       \