Hi!
I'm trying to compile nim generated source code with Android NDK and get the error in generated stdlib_times.c
[armeabi] Compile thumb : test <= stdlib_times.c
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c: In function 'gettimezone_102604':
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: error: 'timezone' undeclared (first use in this function)
result = timezone;
^
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: note: each undeclared identifier is reported only once for each function it appears in
make: *** [/home/user/workspace/nim/sandbox/test/android/obj/local/armeabi/objs/test/__/__/nimcache/stdlib_times.o] Error 1
Line 30 of times.nim defines timezone as following:
var
timezone {.importc, header: "<time.h>".}: int
but I could not find timezone of type int in <time.h>
What's going wrong?
The timezone variable is part of the XSI extension of POSIX; it thus belongs to the "Single UNIX Specification", which most *IXes belong to, but not POSIX proper. And not all POSIX systems implement SUS fully.
That said, a quick look at the NDK sources shows that all but the oldest API levels properly define the timezone variable in time.h, so I'm at bit of a loss here.
If I just do NDK_DEBUG=1 /path/to/android-ndk-r10e/ndk-build, then I get:
[armeabi-v7a] Compile thumb : test <= stdlib_times.c
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c: In function 'gettimezone_102604':
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: error: 'timezone' undeclared (first use in this function)
result = timezone;
^
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: note: each undeclared identifier is reported only once for each function it appears in
make: *** [/home/user/workspace/nim/sandbox/test/android/obj/local/armeabi/objs-debug/test/__/__/nimcache/stdlib_times.o] Error 1
but if I do V=1 /path/to/android-ndk-r10e/ndk-build, then I get:
[armeabi-v7a] Compile thumb : test <= stdlib_times.c
/home/user/workspace/android/android-ndk/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -MMD -MP -MF /home/user/workspace/nim/sandbox/test/android/obj/local/armeabi/objs/test/__/__/nimcache/stdlib_times.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/home/user/workspace/nim/sandbox/test/android/jni -DANDROID -w -I/home/user/workspace/nim/Nim/lib -Wa,--noexecstack -Wformat -Werror=format-security -I/home/user/workspace/android/android-ndk/android-ndk-r10e/platforms/android-3/arch-arm/usr/include -c /home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c -o /home/user/workspace/nim/sandbox/test/android/obj/local/armeabi/objs/test/__/__/nimcache/stdlib_times.o
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c: In function 'gettimezone_102604':
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: error: 'timezone' undeclared (first use in this function)
result = timezone;
^
/home/user/workspace/nim/sandbox/test/android/jni/../../nimcache/stdlib_times.c:966:11: note: each undeclared identifier is reported only once for each function it appears in
make: *** [/home/user/workspace/nim/sandbox/test/android/obj/local/armeabi/objs/test/__/__/nimcache/stdlib_times.o] Error 1
so, probably, no -std options