Skip to content

Commit

Permalink
Document warning configuration and fix strdup (#define based on compi…
Browse files Browse the repository at this point in the history
…ler)
  • Loading branch information
matthiasblaesing committed Oct 5, 2016
1 parent 87606cc commit f3d9bd3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ CC=gcc
LD=$(CC)
LIBS=
# CC_OPTS only applied to objects build for jnidispatch, not for libffi
# -Wno-unknown-warning-option
# => Suppress warning for unknown warnings (CLANG)
# -Werror => Treat warnings as errors
# -Wno-clobbered => Silence GCC warning about clobbered automatic variables.
# The "longjmp" case only happens in protect.h in the logic
# that implements "protected" mode. In that case an exception
# is raised and the value of the potentially clobbered
# variables is ignored.
LOC_CC_OPTS=-Wno-unknown-warning-option -Werror -Wno-clobbered
# Default to Sun recommendations for JNI compilation
COPT=-O2 -fno-omit-frame-pointer -fno-strict-aliasing
Expand Down
2 changes: 1 addition & 1 deletion native/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ initializeThread(callback* cb, AttachOptions* args) {
if (args->name != NULL) {
// Make a copy, since the Java Structure which owns this native memory
// will go out of scope and be available for GC
args->name = strdup(args->name);
args->name = STRDUP(args->name);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions native/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#pragma warning( disable : 4204 ) /* structure initializer */
#pragma warning( disable : 4710 ) /* swprintf not inlined */
#pragma warning( disable : 4201 ) /* nameless struct/union (jni_md.h) */
#pragma warning( disable : 4996 ) /* deprecated functions (strdup) */
#else
#include <malloc.h>
#endif /* _MSC_VER */
Expand Down Expand Up @@ -145,7 +144,7 @@ typedef struct _callback {

#if defined(_MSC_VER)
#include "snprintf.h"
#define strdup _strdup
#define STRDUP _strdup
#if defined(_WIN64)
#define L2A(X) ((void *)(X))
#define A2L(X) ((jlong)(X))
Expand All @@ -155,6 +154,7 @@ typedef struct _callback {
#endif
#else
#include <stdio.h>
#define STRDUP strdup
#endif

/* Convenience macros */
Expand Down

0 comments on commit f3d9bd3

Please sign in to comment.