travis CI: Enforce -std=c89. Also fix all related warnings and errors. This should help Qt team which needs to build MD4C with Integrity compiler for some embedded platforms.
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/.travis.yml b/.travis.yml
index fef67c0..866b512 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,7 +15,9 @@ addons:
before_script:
- mkdir build
- cd build
- - CFLAGS='--coverage -g -O0' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' ..
+ # We enforce C89/90 (-std=c89) because Qt project needs to build MD4C with
+ # Integrity compiler so we need to be quite conservative.
+ - CFLAGS='--coverage -g -O0 -std=c89 -Wall' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' ..
script:
- make VERBOSE=1
diff --git a/md2html/render_html.c b/md2html/render_html.c
index a1f96b2..896b37f 100644
--- a/md2html/render_html.c
+++ b/md2html/render_html.c
@@ -30,11 +30,14 @@
#include "entity.h"
-#ifdef _MSC_VER
- /* MSVC does not understand "inline" when building as pure C (not C++).
- * However it understands "__inline" */
- #ifndef __cplusplus
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199409L
+ /* C89/90 or old compilers in general may not understand "inline". */
+ #if defined __GNUC__
+ #define inline __inline__
+ #elif defined _MSC_VER
#define inline __inline
+ #else
+ #define inline
#endif
#endif
diff --git a/md4c/md4c.c b/md4c/md4c.c
index b38b709..4a92b90 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -35,11 +35,14 @@
*** Miscellaneous Stuff ***
*****************************/
-#ifdef _MSC_VER
- /* MSVC does not understand "inline" when building as pure C (not C++).
- * However it understands "__inline" */
- #ifndef __cplusplus
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199409L
+ /* C89/90 or old compilers in general may not understand "inline". */
+ #if defined __GNUC__
+ #define inline __inline__
+ #elif defined _MSC_VER
#define inline __inline
+ #else
+ #define inline
#endif
#endif
@@ -1467,8 +1470,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)
@@ -4186,6 +4189,8 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
{
const MD_MARK* opener = (mark->ch != ']' ? mark : &ctx->marks[mark->prev]);
const MD_MARK* closer = &ctx->marks[opener->next];
+ const MD_MARK* dest_mark;
+ const MD_MARK* title_mark;
if ((opener->ch == '[' && closer->ch == ']') &&
opener->end - opener->beg >= 2 &&
@@ -4209,10 +4214,9 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines)
break;
}
- const MD_MARK* dest_mark = opener+1;
- const MD_MARK* title_mark = opener+2;
-
+ dest_mark = opener+1;
MD_ASSERT(dest_mark->ch == 'D');
+ title_mark = opener+2;
MD_ASSERT(title_mark->ch == 'D');
MD_CHECK(md_enter_leave_span_a(ctx, (mark->ch != ']'),