Commit 1fabe4ea authored by Fredrik Orderud's avatar Fredrik Orderud

Add work-arounds for C++ features and GCC attributes not supported by Microsoft Visual C++.

parent 556e802e
...@@ -124,7 +124,12 @@ void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const cha ...@@ -124,7 +124,12 @@ void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const cha
const char * file_basename = slash ? slash + 1 : file; const char * file_basename = slash ? slash + 1 : file;
char buf[256]; char buf[256];
#if (defined _MSC_VER) && (_MSC_VER < 1900)
// snprintf not implemented on MSVC prior to 2015
_snprintf(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check);
#else
snprintf(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check); snprintf(buf, sizeof buf, "djinni (%s:%d): %s", file_basename, line, check);
#endif
jclass cassert = env->FindClass("java/lang/AssertionError"); jclass cassert = env->FindClass("java/lang/AssertionError");
assert(cassert); assert(cassert);
...@@ -388,7 +393,11 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) { ...@@ -388,7 +393,11 @@ std::string jniUTF8FromString(JNIEnv * env, const jstring jstr) {
return out; return out;
} }
__attribute__((weak)) #ifdef _MSC_VER
// weak attribute not supported by MSVC
#else
__attribute__((weak))
#endif
void jniSetPendingFromCurrent(JNIEnv * env, const char * /*ctx*/) noexcept { void jniSetPendingFromCurrent(JNIEnv * env, const char * /*ctx*/) noexcept {
try { try {
throw; throw;
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
#include <jni.h> #include <jni.h>
// work-around for missing noexcept and constexpr support in MSVC prior to 2015
#if (defined _MSC_VER) && (_MSC_VER < 1900)
# define noexcept _NOEXCEPT
# define constexpr
#endif
/* /*
* Djinni support library * Djinni support library
*/ */
...@@ -57,7 +63,11 @@ void jniExceptionCheck(JNIEnv * env); ...@@ -57,7 +63,11 @@ void jniExceptionCheck(JNIEnv * env);
/* /*
* Set an AssertionError in env with message message, and then throw jni_exception_pending. * Set an AssertionError in env with message message, and then throw jni_exception_pending.
*/ */
__attribute__((noreturn)) #ifdef _MSC_VER
__declspec(noreturn)
#else
__attribute__((noreturn))
#endif
void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const char * check); void jniThrowAssertionError(JNIEnv * env, const char * file, int line, const char * check);
#define DJINNI_ASSERT(check, env) \ #define DJINNI_ASSERT(check, env) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment