<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 31/07/2024 15:51, Stephen Buergler
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAJxPRwXVXD3x0x9s_cW+O0j_vZpu1=UHYJTyKAxSoz=U_-K+LA@mail.gmail.com">
<div dir="ltr">
<div>I guess so but prototypeless functions seem to work fine
with other tools including when they are brought into C++
builds.</div>
<div>Also right now if someone does go back and fix the header
files it will result in large breaking changes to the
generated jextract bindings.</div>
</div>
</blockquote>
<p>The fix you mention where someone replaces a function from `()`
to `(void)` would also caused all existing compiled code to fail
when calling the updated function (as the calling convention used
by already compiled code is now invalid).</p>
<p>The library file itself says nothing as to whether the function
is prototypeless or not - in fact it says nothing as to whether
the function has 1, 2 or 12 arguments.</p>
<p>In an ideal world, signature information would be part of the
shared library format - then the Linker could use this information
as part of its decision process. But that's not the world we live
in. The correct calling convention is selected at the caller based
on some knowledge of the signature of the function that needs to
be called. In C, it means "by reading a header file". In
FFM/Linker, this means "the user has to provide a description of
what the called function is - e.g. which types are involved, and
whether the function contains any variadic arguments".<br>
</p>
<p>Jextract, alone, cannot help here, because it only sees one side
of the equation: how the native function is declared. But it
doesn't see how the function is called, so it doesn't know,
before-hand, how many arguments you want to pass (this information
is crucial to call a prototype-less function correctly) and of
which type (this information is also crucial as some numeric C
promotions might be required when passing sub-int values to
prototype-less functions).</p>
<p>In understand that, in some cases, the `()` syntax used in a
header might be a bug. But I'm mildly against making assumptions
on what the "header really meant" because... that is just
guessing. If the function really takes no arguments, its signature
really ought to be fixed.<br>
</p>
<blockquote type="cite" cite="mid:CAJxPRwXVXD3x0x9s_cW+O0j_vZpu1=UHYJTyKAxSoz=U_-K+LA@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
Neat but this flag seems to cause other issues.
<div>FATAL: Unexpected exception
org.openjdk.jextract.clang.Index$ParsingFailedException:
Failed to parse ...\librclone.h: ASTReadError occurred<br>
</div>
<div>It's not a very helpful error message.</div>
</div>
</blockquote>
<p>This is not helpful I agree - seems to be coming somewhere deep
in libclang. I wonder if it's related to the parsing of the
compile_flags.txt itself...</p>
Thanks<br>
Maurizio<br>
<blockquote type="cite" cite="mid:CAJxPRwXVXD3x0x9s_cW+O0j_vZpu1=UHYJTyKAxSoz=U_-K+LA@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Jul 15, 2024 at
5:19 AM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com" moz-do-not-send="true" class="moz-txt-link-freetext">maurizio.cimadamore@oracle.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
I don't think jextract should paper over what seem like bugs
in header <br>
files (even if common ones) ?<br>
<br>
I think a possible workaround for dealing with such libraries
is to pass <br>
clang the `-x c++` flag. This can be done as described here:<br>
<br>
<a href="https://urldefense.com/v3/__https://github.com/openjdk/jextract/blob/master/doc/GUIDE.md*additional-clang-options__;Iw!!ACWV5N9M2RV99hQ!LKsa80eHdqMFa9G7ebQHjquG6ySddsHQ6wiyi7XBqYPvzpsjbLSOH9YnAMtfVclhLFzD3vscQ8CMgL3tB1SRTzijs44$" rel="noreferrer" target="_blank">https://github.com/openjdk/jextract/blob/master/doc/GUIDE.md#additional-clang-options</a><br>
<br>
Cheers<br>
Maurizio<br>
<br>
On 15/07/2024 08:08, Stephen Buergler wrote:<br>
> Hello!<br>
> I think most of the time there is something like<br>
> extern void RcloneInitialize();<br>
> is put into a header file it's meant to declare a
function with no <br>
> parameters.<br>
> jextract outputs variadic versions of the binding though
because <br>
> that's not what that means. It means that the function
declaration has <br>
> no prototype and has an unknown number of parameters.<br>
> extern void RcloneInitialize(void);<br>
> This defines a function with no parameters and is what is
usually <br>
> intended and with this version the jextract bindings now
reflect that <br>
> there are no parameters to pass in.<br>
><br>
> Would it make sense to change jextract to be able to
treat these as <br>
> functions that take no parameters?<br>
> Alternatively, would it make sense to provide bindings
for both <br>
> versions of the function?<br>
> If a `public static void RcloneInitialize()` and the
variadic version <br>
> existed I think that would make sense.<br>
><br>
</blockquote>
</div>
</blockquote>
</body>
</html>