Build: With gcc and clang, enforce -std=c90. See #71. This forces us to be more conservative in the future code changes, and make us more friendly mainly to some embedded compilers who are often behind the current state of art. Fix also related warnings and errors, as provided by gcc 8.1.0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12674d7..6ac7ede 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ endif()
if(${CMAKE_C_COMPILER_ID} MATCHES GNU|Clang)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c90")
elseif(MSVC)
# Disable warnings about the so-called unsecured functions:
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
diff --git a/md2html/render_html.c b/md2html/render_html.c
index 9fc62f8..e215f6e 100644
--- a/md2html/render_html.c
+++ b/md2html/render_html.c
@@ -30,14 +30,18 @@
#include "entity.h"
-#ifdef _MSC_VER
- /* MSVC does not understand "inline" when building as pure C (not C++).
- * However it understands "__inline" */
- #ifndef __cplusplus
+/* Inline keyword has been added in C99. */
+#if __STDC_VERSION__ < 199901L
+ #if defined _MSC_VER
#define inline __inline
+ #elif defined __GNUC__
+ #define inline __inline__
+ #else
+ #define inline
#endif
#endif
+
#ifdef _WIN32
#define snprintf _snprintf
#endif
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 5fe7b01..e3fecfb 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -35,14 +35,18 @@
*** Miscellaneous Stuff ***
*****************************/
-#ifdef _MSC_VER
- /* MSVC does not understand "inline" when building as pure C (not C++).
- * However it understands "__inline" */
- #ifndef __cplusplus
+/* Inline keyword has been added in C99. */
+#if __STDC_VERSION__ < 199901L
+ #if defined _MSC_VER
#define inline __inline
+ #elif defined __GNUC__
+ #define inline __inline__
+ #else
+ #define inline
#endif
#endif
+
#ifdef _T
#undef _T
#endif
@@ -1514,8 +1518,8 @@ abort:
*** Dictionary of Reference Definitions ***
*********************************************/
-#define MD_FNV1A_BASE 2166136261
-#define MD_FNV1A_PRIME 16777619
+#define MD_FNV1A_BASE 2166136261U
+#define MD_FNV1A_PRIME 16777619U
static inline unsigned
md_fnv1a(unsigned base, const void* data, size_t n)