diff --git a/Makefile b/Makefile index 6a06ec33..f7ebab39 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SRCS = mongoose.c test/unit_test.c test/packed_fs.c HDRS = $(wildcard src/*.h) DEFS ?= -DMG_MAX_HTTP_HEADERS=7 -DMG_ENABLE_LINES -DMG_ENABLE_PACKED_FS=1 -WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wmissing-prototypes +WARN ?= -W -Wall -Werror -Wshadow -Wdouble-promotion -fno-common -Wconversion -Wmissing-prototypes -Wundef OPTS ?= -O3 -g3 INCS ?= -Isrc -I. CFLAGS ?= $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) $(EXTRA) diff --git a/mongoose.c b/mongoose.c index 4b18ad6b..59398ad8 100644 --- a/mongoose.c +++ b/mongoose.c @@ -689,8 +689,9 @@ static size_t p_write(void *fp, const void *buf, size_t len) { } static size_t p_seek(void *fp, size_t offset) { -#if _FILE_OFFSET_BITS == 64 || _POSIX_C_SOURCE >= 200112L || \ - _XOPEN_SOURCE >= 600 +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || \ + (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \ + (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) fseeko((FILE *) fp, (off_t) offset, SEEK_SET); #else fseek((FILE *) fp, (long) offset, SEEK_SET); @@ -1867,7 +1868,7 @@ void mg_log_set_callback(void (*fn)(const void *, size_t, void *), void *fnd) { #include -#if MG_ENABLE_MD5 +#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5 #if !defined(BYTE_ORDER) && defined(__BYTE_ORDER) #define BYTE_ORDER __BYTE_ORDER #ifndef LITTLE_ENDIAN @@ -3158,7 +3159,7 @@ static void setsockopts(struct mg_connection *c) { setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)); #endif setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)); -#if ESP32 || ESP8266 || defined(__linux__) +#if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || defined(__linux__) int idle = 60; setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)); #endif @@ -3699,7 +3700,7 @@ void mg_timer_poll(unsigned long now_ms) { #endif #endif -#if MBEDTLS_VERSION_NUMBER >= 0x03000000 +#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_NUMBER >= 0x03000000 #define RNG , rng_get, NULL #else #define RNG @@ -3749,7 +3750,7 @@ static void debug_cb(void *c, int lev, const char *s, int n, const char *s2) { (void) lev; } -#if MBEDTLS_VERSION_NUMBER >= 0x03000000 +#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_NUMBER >= 0x03000000 static int rng_get(void *p_rng, unsigned char *buf, size_t len) { (void) p_rng; mg_random(buf, len); diff --git a/src/fs_posix.c b/src/fs_posix.c index 5f17c551..d9b6d3ca 100644 --- a/src/fs_posix.c +++ b/src/fs_posix.c @@ -176,8 +176,9 @@ static size_t p_write(void *fp, const void *buf, size_t len) { } static size_t p_seek(void *fp, size_t offset) { -#if _FILE_OFFSET_BITS == 64 || _POSIX_C_SOURCE >= 200112L || \ - _XOPEN_SOURCE >= 600 +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || \ + (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \ + (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) fseeko((FILE *) fp, (off_t) offset, SEEK_SET); #else fseek((FILE *) fp, (long) offset, SEEK_SET); diff --git a/src/md5.c b/src/md5.c index 4b1e3d17..5d42a913 100644 --- a/src/md5.c +++ b/src/md5.c @@ -1,7 +1,7 @@ #include #include "md5.h" -#if MG_ENABLE_MD5 +#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5 #if !defined(BYTE_ORDER) && defined(__BYTE_ORDER) #define BYTE_ORDER __BYTE_ORDER #ifndef LITTLE_ENDIAN diff --git a/src/sock.c b/src/sock.c index 7eb60efe..d268ea2d 100644 --- a/src/sock.c +++ b/src/sock.c @@ -316,7 +316,7 @@ static void setsockopts(struct mg_connection *c) { setsockopt(FD(c), SOL_TCP, TCP_QUICKACK, (char *) &on, sizeof(on)); #endif setsockopt(FD(c), SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)); -#if ESP32 || ESP8266 || defined(__linux__) +#if (defined(ESP32) && ESP32) || (defined(ESP8266) && ESP8266) || defined(__linux__) int idle = 60; setsockopt(FD(c), IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)); #endif diff --git a/src/tls.c b/src/tls.c index 9c7d8fac..04c36f6e 100644 --- a/src/tls.c +++ b/src/tls.c @@ -16,7 +16,7 @@ #endif #endif -#if MBEDTLS_VERSION_NUMBER >= 0x03000000 +#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_NUMBER >= 0x03000000 #define RNG , rng_get, NULL #else #define RNG @@ -66,7 +66,7 @@ static void debug_cb(void *c, int lev, const char *s, int n, const char *s2) { (void) lev; } -#if MBEDTLS_VERSION_NUMBER >= 0x03000000 +#if defined(MBEDTLS_VERSION_NUMBER) && MBEDTLS_VERSION_NUMBER >= 0x03000000 static int rng_get(void *p_rng, unsigned char *buf, size_t len) { (void) p_rng; mg_random(buf, len);