Commit 716b6ca4448318df900eb22bb7a31499a827d905

Martin Mitas 2019-04-17T15:01:03

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.

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)