Macro definition is seen in the jar file with a constant generated, but the #ifndef check doesn't work in the c file which does a check on the macro definition #65
I am trying to use a C open source project in my Java application. Configured JNAerator and BridJ and it generates a proper jar file. However, I get an issue while invoking the APIs in the jar.
I want to call a C funtion which has 2 versions. Want to call either of the versions based on a FLAG or macro defined. I defined the macro and it results in a java class final constant generated in the macro name. but the #ifndef check for the macro definition and executing the different versions of the API based on the result, doesn't work. Any change required to the order of c files and header files? Ultimately the JVM crashes. Need your help.
To elaborate what I am trying and what happened,
Trying to wrap the c client from libtacplus-0.2.tgz from http://sourceforge.net/projects/libtacplus/files/libtacplus/libtacplus%200.2/
and was trying to edit tac_utils.c for using the method getaddrinfo() instead of the the deprecated method gethostbyname(). Tried to add a CPPFLAGS in the Bridj Makefile to switch between the deprecated and the new method usage. But the recompilation of the new c file doesn't seem to be reflecting the changes. The error is still thrown with gethostbyname() and the jvm crashes. Please help with what I am missing. Why aren't the changes picked by BridJ . Requesting response at the earliest.
Copied from original issue: ochafik/nativelibs4java#507
From @Urge2Learn on May 23, 2014 11:12
Hi Oliver,
I am trying to use a C open source project in my Java application. Configured JNAerator and BridJ and it generates a proper jar file. However, I get an issue while invoking the APIs in the jar. I want to call a C funtion which has 2 versions. Want to call either of the versions based on a FLAG or macro defined. I defined the macro and it results in a java class final constant generated in the macro name. but the #ifndef check for the macro definition and executing the different versions of the API based on the result, doesn't work. Any change required to the order of c files and header files? Ultimately the JVM crashes. Need your help.
To elaborate what I am trying and what happened,
Trying to wrap the c client from libtacplus-0.2.tgz from http://sourceforge.net/projects/libtacplus/files/libtacplus/libtacplus%200.2/ and was trying to edit tac_utils.c for using the method getaddrinfo() instead of the the deprecated method gethostbyname(). Tried to add a CPPFLAGS in the Bridj Makefile to switch between the deprecated and the new method usage. But the recompilation of the new c file doesn't seem to be reflecting the changes. The error is still thrown with gethostbyname() and the jvm crashes. Please help with what I am missing. Why aren't the changes picked by BridJ . Requesting response at the earliest.
Copied from original issue: ochafik/nativelibs4java#507