ref: de2bbb38c989acdd89310b4f8a2d04b1c5402e2b
parent: df846b08571664c312fa3c5e316db8ca24ba4d80
author: Kubo Takehiro <kubo@jiubao.org>
date: Sun Jun 24 14:54:00 EDT 2018
Fix undefined reference to c99_vsnprintf and ts_utf8_sequence_length when using mingw32 gcc. The mingw32 gcc compiler doesn't treat __inline as Visual C++ does. Use `static inline` instead of `__inline` for c99_vsnprintf. Don't use `__inline` for ts_utf8_sequence_length.
--- a/include/cst_file.h
+++ b/include/cst_file.h
@@ -101,7 +101,13 @@
#ifdef _WIN32
#define snprintf c99_snprintf
-__inline int c99_vsnprintf(char* str, size_t size, const char* format,
+#ifdef __GNUC__
+#define INLINE static inline
+#else
+#define INLINE __inline
+#endif
+
+INLINE int c99_vsnprintf(char* str, size_t size, const char* format,
va_list ap) {
int count = -1;
if (size != 0)
@@ -110,7 +116,7 @@
count = _vscprintf(format, ap);
return count;
}
-__inline int c99_snprintf(char* str, size_t size, const char* format, ...)
+INLINE int c99_snprintf(char* str, size_t size, const char* format, ...)
{
int count;
va_list ap;
--- a/include/cst_tokenstream.h
+++ b/include/cst_tokenstream.h
@@ -130,7 +130,7 @@
int (*getc)(cst_tokenstream *ts));
void ts_close(cst_tokenstream *ts);
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
__inline int ts_utf8_sequence_length(char c0);
#else
int ts_utf8_sequence_length(char c0);
--- a/src/utils/cst_tokenstream.c
+++ b/src/utils/cst_tokenstream.c
@@ -266,7 +266,7 @@
(*buffer)[p] = '\0';
}
- #ifdef _WIN32
+ #if defined _WIN32 && !defined(__GNUC__)
__inline int ts_utf8_sequence_length(char c0)
#else
int ts_utf8_sequence_length(char c0)