浏览代码

stdint.h (from C99) is no longer optional

Around 17 years after the C99 standard has been released,
we can require every compiler / standard library to support it.
The "HAVE_STDINT" define is removed - you are supposed to have stdint.h !

In case you are still using a toolchain without stdint.h, such as
Visual Studio prior to 2010, you have to add an stdint.h file yourself.
For Visual Studio, you might want to use "msinttypes" (can be found here:
https://github.com/chemeris/msinttypes), or your own implementation.
For other outdated compilers, you might have to write stdint.h on your own.

See also #365
bel 8 年之前
父节点
当前提交
a076201c4d
共有 3 个文件被更改,包括 5 次插入20 次删除
  1. 0 6
      CMakeLists.txt
  2. 5 13
      src/civetweb.c
  3. 0 1
      test/private.c

+ 0 - 6
CMakeLists.txt

@@ -359,16 +359,10 @@ if (CIVETWEB_ENABLE_CXX)
   add_cxx_compiler_flag(--coverage COVERAGE)
 endif()
 
-# Check the headers we need
-check_include_files(stdint.h HAVE_STDINT)
-
 # Set up the definitions
 if (${CMAKE_BUILD_TYPE} MATCHES "[Dd]ebug")
   add_definitions(-DDEBUG)
 endif()
-if (HAVE_STDINT)
-  add_definitions(-DHAVE_STDINT)
-endif()
 if (CIVETWEB_ENABLE_IPV6)
   add_definitions(-DUSE_IPV6)
 endif()

+ 5 - 13
src/civetweb.c

@@ -229,6 +229,11 @@ _civet_safe_clock_gettime(int clk_id, struct timespec *t)
 #include <limits.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <stdint.h>
+
+#ifndef INT64_MAX
+#define INT64_MAX (9223372036854775807)
+#endif
 
 
 #ifndef MAX_WORKER_THREADS
@@ -405,19 +410,6 @@ static void path_to_unicode(const struct mg_connection *conn,
 static const char *
 mg_fgets(char *buf, size_t size, struct mg_file *filep, char **p);
 
-#define HAVE_STDINT
-#if defined(HAVE_STDINT)
-#include <stdint.h>
-#else
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned __int64 uint64_t;
-typedef __int64 int64_t;
-#ifndef INT64_MAX
-#define INT64_MAX (9223372036854775807)
-#endif
-#endif /* HAVE_STDINT */
 
 /* POSIX dirent interface */
 struct dirent {

+ 0 - 1
test/private.c

@@ -31,7 +31,6 @@
 #endif
 
 #ifdef REPLACE_CHECK_FOR_LOCAL_DEBUGGING
-#define HAVE_STDINT
 #undef MEMORY_DEBUGGING
 #endif