<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi,<br>
I'm not an expert here -- but I see there's some options to force
the compiler to emit symbols for inline functions. For instance I
see this:</p>
<p>
<blockquote type="cite">-fkeep-inline-functions<br>
In C, emit "static" functions that are declared
"inline" into the<br>
object file, even if the function has been inlined
into all of its<br>
callers. This switch does not affect functions using
the "extern<br>
inline" extension in GNU C90. In C++, emit any and
all inline<br>
functions into the object file.<br>
</blockquote>
<br>
I've seen also some pragmas being mentioned -- such as this:</p>
<p><a class="moz-txt-link-freetext" href="https://clang.llvm.org/docs/AttributeReference.html#used">https://clang.llvm.org/docs/AttributeReference.html#used</a></p>
<p>Of course your mileage might vary -- different compilers might
support different options, or work in slightly different ways.</p>
<p>And -- the problem is that you have little/no control over
whether inline symbols are emitted or not. E.g. if you install a
C++ lib on your system, inline functions will either be there, or
they won't. If they aren't there there's not much you can do to
alter that, except creating a shim library which re-exports the
inline symbols. But at that point you are no longer in "pure"
Java.</p>
<p>I think the shim library approach is actually not a bad idea --
especially the generation of such a shim library could be
automated completely -- e.g. some sort of C++ to C transpiler.
But, unfortunately, while there have been many experiments along
those lines, they all seem to be abandoned at some point
(typically when they get to exceptions and/or templates :-) ).<br>
</p>
<p>Maurizio<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 05/03/2025 05:30, Lain Lain wrote:<br>
</div>
<blockquote type="cite" cite="mid:trinity-720d61e8-4f56-48a6-bcc6-4f196d557886-1741152600413@3c-app-mailcom-lxa05">
<pre>Do we know if someone is working with C++ committee to include new
keywords to C++ to help creating bindings? This is not only Java but
many other languages could benefit from (Rust, ...)
For example, inline functions are mainly for optimization purposes. If
compilers knew that inline function may be accessed from other languages
they could, in addition to inlining it everywhere, preserve the
original function so that bindings could access it. Something like
keyword "extern" which we already have.</pre>
</blockquote>
</body>
</html>