History

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.

Kubo Takehiro committed 8 years ago

Commit de2bbb31 parent df846b03 files · +10 −4Browse files

Unified · Split

3 files
  1. include/cst_file.h +8 −2
  2. include/cst_tokenstream.h +1 −1
  3. src/utils/cst_tokenstream.c +1 −1
include/cst_file.h+8−2
@@ -101,7 +101,13 @@ int cst_sprintf(char *s, const char *fmt, ...); · 100 unmodified lines
101101 #ifdef _WIN32
102102 #define snprintf c99_snprintf
103103
104−__inline int c99_vsnprintf(char* str, size_t size, const char* format,
104+#ifdef __GNUC__
105+#define INLINE static inline
106+#else
107+#define INLINE __inline
108+#endif
109+
110+INLINE int c99_vsnprintf(char* str, size_t size, const char* format,
105111 va_list ap) {
106112 int count = -1;
107113 if (size != 0)
@@ -110,7 +116,7 @@ va_list ap) { · 2 unmodified lines
110116 count = _vscprintf(format, ap);
111117 return count;
112118 }
113−__inline int c99_snprintf(char* str, size_t size, const char* format, ...)
119+INLINE int c99_snprintf(char* str, size_t size, const char* format, ...)
114120 {
115121 int count;
116122 va_list ap;
include/cst_tokenstream.h+1−1
@@ -130,7 +130,7 @@ cst_tokenstream *ts_open_generic(const char *filename, · 129 unmodified lines
130130 int (*getc)(cst_tokenstream *ts));
131131 void ts_close(cst_tokenstream *ts);
132132
133−#ifdef _WIN32
133+#if defined(_WIN32) && !defined(__GNUC__)
134134 __inline int ts_utf8_sequence_length(char c0);
135135 #else
136136 int ts_utf8_sequence_length(char c0);
src/utils/cst_tokenstream.c+1−1
@@ -266,7 +266,7 @@ static void get_token_sub_part(cst_tokenstream *ts, · 265 unmodified lines
266266 (*buffer)[p] = '\0';
267267 }
268268
269− #ifdef _WIN32
269+ #if defined _WIN32 && !defined(__GNUC__)
270270 __inline int ts_utf8_sequence_length(char c0)
271271 #else
272272 int ts_utf8_sequence_length(char c0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t