*
**************************************************************************/
+#include "no_extern_c.h"
+
#ifndef _C99_COMPAT_H_
#define _C99_COMPAT_H_
+/*
+ * MSVC hacks.
+ */
+#if defined(_MSC_VER)
+
+# if _MSC_VER < 1500
+# error "Microsoft Visual Studio 2008 or higher required"
+# endif
+
+ /*
+ * Visual Studio 2012 will complain if we define the `inline` keyword, but
+ * actually it only supports the keyword on C++.
+ *
+ * To avoid this the _ALLOW_KEYWORD_MACROS must be set.
+ */
+# if (_MSC_VER >= 1700) && !defined(_ALLOW_KEYWORD_MACROS)
+# define _ALLOW_KEYWORD_MACROS
+# endif
+
+ /*
+ * XXX: MSVC has a `__restrict` keyword, but it also has a
+ * `__declspec(restrict)` modifier, so it is impossible to define a
+ * `restrict` macro without interfering with the latter. Furthermore the
+ * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT
+ * macro. For now resolve this issue by redefining _CRTRESTRICT, but going
+ * forward we should probably should stop using restrict, especially
+ * considering that our code does not obbey strict aliasing rules any way.
+ */
+# include <crtdefs.h>
+# undef _CRTRESTRICT
+# define _CRTRESTRICT
+#endif
+
+
/*
* C99 inline keyword
*/
# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
/* C99 */
# elif defined(__GNUC__)
-# if __GNUC__ >= 2
-# define __func__ __FUNCTION__
-# else
-# define __func__ "<unknown>"
-# endif
+# define __func__ __FUNCTION__
# elif defined(_MSC_VER)
-# if _MSC_VER >= 1300
-# define __func__ __FUNCTION__
-# else
-# define __func__ "<unknown>"
-# endif
+# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
+/* Simple test case for debugging */
+#if 0
+static inline const char *
+test_c99_compat_h(const void * restrict a,
+ const void * restrict b)
+{
+ return __func__;
+}
+#endif
+
+
#endif /* _C99_COMPAT_H_ */