Login  Register

Need help with parsing stdio.h

Posted by soma on Mar 03, 2014; 6:04pm
URL: https://forum.jogamp.org/Need-help-with-parsing-stdio-h-tp4031763.html

Dear All,

I've just started to work with GlueGen, with the goal of using from Java the C software running at an observatory.

I successfully built GlueGen 2.1.4 from scratch on Scientific Linux 5.5, from the downloaded "gluegen-v2.1.4.tar.7z" archive.
When I try to generate JNI code from any header file that includes "stdio.h", or using that include file directly, I get the following error:

gluegen-v2.1.4/build 1397 > java -jar gluegen.jar -I/usr/include -CmyGlueGen.cfg /usr/include/stdio.h
Exception in thread "main" java.lang.RuntimeException: Exception occurred while generating glue code.
        at com.jogamp.gluegen.GlueGen.run(GlueGen.java:307)
        at com.jogamp.gluegen.GlueGen.main(GlueGen.java:366)
Caused by: java.io.IOException: Expected token '40' but got '__need_FILE' at file /usr/include/stdio.h, line 23
        at com.jogamp.gluegen.pcpp.PCPP.nextRequiredToken(PCPP.java:279)
        at com.jogamp.gluegen.pcpp.PCPP.handleIfRecursive(PCPP.java:935)
        at com.jogamp.gluegen.pcpp.PCPP.handleIfRecursive(PCPP.java:886)
        at com.jogamp.gluegen.pcpp.PCPP.handleIf(PCPP.java:831)
        at com.jogamp.gluegen.pcpp.PCPP.preprocessorDirective(PCPP.java:410)
        at com.jogamp.gluegen.pcpp.PCPP.parse(PCPP.java:338)
        at com.jogamp.gluegen.pcpp.PCPP.run(PCPP.java:111)
        at com.jogamp.gluegen.GlueGen.run(GlueGen.java:115)

The manual mentions that "PCPP contains only limited support for #if clauses. Generally speaking, its handling of #if defined(foo) || defined(bar) constructs is limited to approximately what is required to handle the OpenGL header files."

This could be such a case, since stdio.h line 23 has
#if !defined __FILE_defined && defined __need_FILE

On the other hand I cannot believe that I'm the first user of GlueGen who needs to parse stdio.h...
It seems that at http://jogamp.org/log/irc/jogamp_20130808100906.html user doby discussed the same issue, but I don't see a conclusion there.
I suspect that in my case the problem is not with command line vs. ant and antlr.jar on the classpath, since the error occurs while already parsing the header file.

Can anyone tell me what I'm doing wrong here, or point me to a working example that uses stdio.h?