On Thu, 1 Aug 2024 12:40:35 GMT, Maurizio Cimadamore <mcimadamore@openjdk.org> wrote:
This PR fixes a bunch of issues with trying to run jextract in CPP mode, using a `compile_flags.txt` file containing the `-xc++` flag.
I've found at least three issues: * extern C clauses are not recursively scanned * the first time we see a cursor with language != C, we stop with an exception (instead of skipping) * typing of enum constant is different in C++ and causes infinite recursion
These issues were preventing jextract to work with real world libraries (I tested OpenGL) when `-xc++` was specified.
Now jextract will try to parse as much as possible. Unrecognized constructs/languages will be skipped and a diagnostic will be reported by the log.
src/main/java/org/openjdk/jextract/impl/TreeMaker.java line 131:
129: private boolean isAllowedCXXDecl(Cursor cursor) { 130: return switch (cursor.kind()) { 131: case StaticAssert, StructDecl, UnionDecl -> true;
When in C++ mode, both structs and unions are reported to have language C++ (understandable, since they can also contain more members, such as methods). So we need to add a list of the constructs we like, regardless of the language.
Why is `StaticAssert` here as well? ------------- PR Review Comment: https://git.openjdk.org/jextract/pull/256#discussion_r1752284626