Login  Register

Re: __stdcall not recognized

Posted by Sven Gothel on Jun 19, 2011; 9:31am
URL: https://forum.jogamp.org/stdcall-not-recognized-tp3079928p3082244.html

On Saturday, June 18, 2011 11:04:23 PM Wade Walker [via jogamp] wrote:

>
> Hi Dino,
>
> It looks like you might have to modify gluegen's C grammar slightly to make
> this work. If you check out the source and look in
> gluegen/src/java/com/jogamp/gluegen/cgram, you can see the ANTLR grammar
> files there (the *.g files). Inside HeaderParser.g and StdCParser.g, you can
> see the definitions for the functionDef and functionDeclSpecifiers grammar
> rules don't include any mention of __stdcall (since this is a
> Microsoft-specific extension).
>

well, actually we .. and khronos headers, and usually all others,
use macro definitions to get around this non std qualifier.

However .. sure, you may patch gluegen as Wade suggest as well.
If so, pls offer me a git pull .. w/ unit tests, thx.

~Sven

> To fix it quick and dirty, you should be able to simply add __stdcall
> something like this:
>
>
> functionDef {
>     TypeBox tb = null;
> }
>         :   #( NFunctionDef
>                 ( functionDeclSpecifiers)?
>                 declarator[tb]
>                 ("__stdcall")?
>                 (declaration | VARARGS)*
>                 compoundStatement
>             )
>         ;
>
>
> I'm not quite sure where it goes in the grammar rule -- you might have to
> poke around a bit and make sure. And it may also need to go in other
> occurrences of functionDef in other *.g files.
>
> Once you've fixed the grammar, recompile gluegen (making sure the ANTLR
> parser generation step doesn't throw any errors) and test it out on your
> input file.
>
> To fix this "for real", you'd probably need to do what they've done for GNU
> C -- create a new .g file for MS C and just override the parts of the
> grammar that are different. See the GnuC*.g files for an example.