Markus Mottl avatar Markus Mottl committed fd02eba

Improved portability by better supporting C99 and non-GNU compilers in bin-prot

Comments (0)

Files changed (1)

base/bin-prot/lib/common_stubs.h

 extern value *v_bin_prot_exc_Buffer_short;
 
 
-/* GNU compiler pragmas */
+/* Compiler pragmas and inlining */
 
-#if __GNUC__ >= 3
+/* Forget any previous definition of inlining, it may not be what we mean */
+#ifdef inline
+# undef inline
+#endif
+
+/* The semantics of "inline" in C99 is not what we intend so just drop it */
+#if defined(__STDC__) && __STDC__ && \
+    defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+# define inline
+#endif
+
+#if defined(__GNUC__) && __GNUC__ >= 3
 # ifndef inline
 #   define inline inline __attribute__ ((always_inline))
 # endif
 #   define unlikely(x) __builtin_expect (!!(x), 0)
 # endif
 #else
+  /* Non-GNU compilers should always ignore "inline" no matter the C-standard */
 # ifndef inline
 #   define inline
 # endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.