How do you use jextract for two or more header files?

carl dea carl.dea at gmail.com
Mon Aug 23 04:25:24 UTC 2021


Panama Dev team,

I'm trying to use jextract for stdio.h and time.h, but getting compile
issues when the target (-t) name space is the same such as *-t org.unix*
*jextract stdio.h*

# jextract stdio.h
jextract --source -d generated/src -t org.unix \
  -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
\
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h

*jextract time.h*

# jextract time.h
jextract --source -d generated/src -t org.unix \
  -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
\
   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/time.h

*Compile source*

javac -d classes generated/src/org/unix/*.java


*Compile Error*
The following compile errors (87 errors)
generated/src/org/unix/stdio_h.java:732: error: cannot find symbol
        return
RuntimeHelper.requireNonNull(constants$0.renameat$MH,"renameat");
                                                       ^
  symbol:   variable renameat$MH
  location: class constants$0
generated/src/org/unix/stdio_h.java:735: error: cannot find symbol
...

*Workaround (change namespace)*
My workaround is making time.h 's target namespace to *-t org.unix.time*.
When I'm in the IDE and using Panama the source code looks like the
following

import static org.unix.stdio_h.*;
import static org.unix.time.time_h.*;

import org.unix.time.tm;
...
// more code
localtime_r(now2, pTmStruct);

Is there a better way to perform a jextract on two more headers?

This example uses both stdio.h and time.h
https://github.com/carldea/panama4newbies/blob/main/part03/src/PanamaTime.java


Thank you,
Carl

-- 
*Carl Dea*
  Email: carldea at gmail.com
Website: https://carlfx.wordpress.com
Twitter: @carldea <https://twitter.com/carldea>


More information about the panama-dev mailing list