<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Dear all,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Today I tried to use jextract on sd-daemon.h (from systemd) to access the sd_notify* class of functions. To my surprise this did not work and returned in the following error message:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:monospace"><span style="color:rgb(24,24,178);background-color:rgb(255,255,255)">../jextract-21/bin/jextract </span><span style="color:rgb(24,178,178);background-color:rgb(255,255,255)">--source -t foo.bar </span><span style="color:rgb(24,178,178);background-color:rgb(255,255,255)">/usr/include/systemd/sd-daemon.h</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">WARNING: A restricted method in java.lang.foreign.AddressLayout has been called</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">WARNING: java.lang.foreign.AddressLayout::withTargetLayout has been called by module org.openjdk.jextract</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">WARNING: Use --enable-native-access=org.openjdk.jextract to avoid a warning for this module</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br>
<br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">/usr/include/systemd/_sd-common.h:23:4: error: "Do not include _sd-common.h directly; it is a private header."</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"></span></span><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">which comes down to the following preprocessor code in _sd-common.h (which is included by sd-daemon.h):</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">#if defined(__INCLUDE_LEVEL__) && __INCLUDE_LEVEL__ <= 1 && !defined(__COVERITY__)</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"># error "Do not include _sd-common.h directly; it is a private header."</span><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">
</span><br><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">#endif</span><br></span></div><br><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">It seems like jextract does not increase the __INCLUDE_LEVEL__ resulting in this error. However, it does seem to define it which makes this more curious.</span></div><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">The fix would be to either a) not set it at all or b) correctly increment it when parsing files from an #include statement.</span></div><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></span></div><div><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">For now I have been able to circumvent this by telling jextract to also define </span><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)">__COVERITY__<span class="gmail_default" style="font-family:arial,helvetica,sans-serif"> though this is only a very dirty hack and will not work in every instance.</span></span></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></span></span></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">Cheers,</span></span></span></div><div><span style="font-family:monospace"><span style="color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">Nils</span></span></span></div></div>