gluegen
gluegen copied to clipboard
Fix casting in Buffers.c
When first trying to build from the latest master branch, I got this error:
gluegen.build.c.impl:
[echo] clearing gluegen.build.shasum.done (2) - was ${gluegen.build.shasum.done}
[echo] Output lib name = gluegen_rt -> libgluegen_rt.dylib [shared]
[mkdir] Created dir: /Users/SiboVanGool/Desktop/Sibo/Projects/OpenRocket/Software/jogamp-SiboVG/gluegen/build/obj
[echo] Compiling src/native/unix/*.c src/native/common/*.c
[echo] user.dir=/Users/SiboVanGool/Desktop/Sibo/Projects/OpenRocket/Software/jogamp-SiboVG/gluegen/make
[cc] 7 total files to be compiled.
[cc] /Users/SiboVanGool/Desktop/Sibo/Projects/OpenRocket/Software/jogamp-SiboVG/gluegen/src/native/common/Buffers.c:28:52: warning: pointer/integer type mismatch in conditional expression ('void *' and 'jlong' (aka 'long long')) [-Wconditional-type-mismatch]
[cc] return ( 0 != jdest && 0 != jsrc && 0 < jlen ) ? memcpy((void *)(intptr_t)jdest, (void *)(intptr_t)jsrc, (size_t)jlen) : jdest;
[cc] ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
[cc] /Users/SiboVanGool/Desktop/Sibo/Projects/OpenRocket/Software/jogamp-SiboVG/gluegen/src/native/common/Buffers.c:28:12: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'jlong' (aka 'long long') [-Wint-conversion]
[cc] return ( 0 != jdest && 0 != jsrc && 0 < jlen ) ? memcpy((void *)(intptr_t)jdest, (void *)(intptr_t)jsrc, (size_t)jlen) : jdest;
[cc] ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[cc] 1 warning and 1 error generated.
The issue was a mismatch in the Java_com_jogamp_common_nio_Buffers_memcpyImpl
function. Specifically, the return type of the function is jlong
, but the conditional expression returns either the result of memcpy
(which is a void*
) or jdest
(which is a jlong
). To resolve this, I cast the return value of memcpy
to jlong
.