Skip to content

Commit a676e3a

Browse files
committed
fix building under newer xcode, fix compiler warning
1 parent 8a5265c commit a676e3a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

native/Makefile

+10-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OS=$(shell uname | sed -e 's/CYGWIN.*/win32/g' \
4747
-e 's/Linux.*/linux/g')
4848

4949
JNA_JNI_VERSION=3.6.0 # auto-generated by ant
50-
CHECKSUM=9798f03f944a9144703939cb42256762 # auto-generated by ant
50+
CHECKSUM=e1ef1f9431f659b9adfbf981f169c5d5 # auto-generated by ant
5151

5252
JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \
5353
-I"$(JAVA_HOME)/include/$(OS)"
@@ -279,6 +279,7 @@ endif
279279

280280

281281
ifeq ($(OS),darwin)
282+
XCODE_VERSION=$(shell xcodebuild -version | grep Xcode | sed 's/^Xcode \([1-9]\).*/\1/g')
282283
JAVA_INCLUDES=-I/System/Library/Frameworks/JavaVM.framework/Headers
283284
DEFAULT_ARCH=$(shell arch)
284285
ARCH=$(shell arch)
@@ -292,15 +293,20 @@ ifneq ($(ARCH),x86_64)
292293
ALT_ARCHS+=x86_64
293294
endif
294295
ifneq ($(ARCH),ppc)
296+
# not supported on XCode 4+
297+
ifeq ($(XCODE_VERSION),3)
295298
ALT_ARCHS+=ppc
296299
endif
300+
endif
297301
LIBSFX=.dylib
298302
JNISFX=.jnilib
299303
ifneq ($(SDKROOT),)
300304
SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT)
301305
ISYSROOT=-isysroot $(SDKROOT)
302-
ARCHFLAGS=-arch i386 -arch x86_64 -arch ppc
303-
#ARCHFLAGS=-arch i386 -arch x86_64
306+
ARCHFLAGS=-arch i386 -arch x86_64
307+
ifeq ($(XCODE_VERSION),3)
308+
ARCHFLAGS+=-arch ppc
309+
endif
304310
endif
305311

306312
PCFLAGS+=$(ISYSROOT) -x objective-c
@@ -310,6 +316,7 @@ LDFLAGS=$(ARCHFLAGS) -dynamiclib -o $@ -framework JavaVM \
310316
-current_version $(JNA_JNI_VERSION) \
311317
-mmacosx-version-min=10.3 \
312318
-framework Foundation \
319+
-Wl,-no_compact_unwind \
313320
-install_name ${@F} \
314321
$(SYSLIBROOT)
315322
# JAWT linkage handled by -framework JavaVM

native/dispatch.c

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
#endif
7474

7575
#include <stdlib.h>
76+
// Force XSI-compliant strerror_r (http://unixhelp.ed.ac.uk/CGI/man-cgi?strerror)
77+
#define _XOPEN_SOURCE 600
7678
#include <string.h>
7779
#include <wchar.h>
7880
#include <jni.h>

test/com/sun/jna/LastErrorTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void testThrowLastError() {
8787
}
8888
catch(LastErrorException e) {
8989
assertEquals("Exception should contain error code", ERROR, e.getErrorCode());
90+
assertTrue("Exception should include error message: " + e.getMessage(), e.getMessage().length() > 10);
9091
}
9192
}
9293

@@ -102,6 +103,7 @@ public void testThrowLastErrorDirect() {
102103
}
103104
catch(LastErrorException e) {
104105
assertEquals("Exception should contain error code", ERROR, e.getErrorCode());
106+
assertTrue("Exception should include error message: " + e.getMessage(), e.getMessage().length() > 10);
105107
}
106108
}
107109

0 commit comments

Comments
 (0)