[ffigen] Explicit '' as name for anon structs/unions (#552)
diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart index a88f5fc..93d662d 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/compounddecl_parser.dart
@@ -300,16 +300,21 @@ // otherwise they will be added in the next iteration. if (!cursor.isAnonymousRecordDecl()) break; + // Anonymous members are always unnamed. To avoid environment- + // dependent naming issues with the generated code, we explicitly + // use the empty string as spelling. + final spelling = ''; + parsed.compound.members.add( Member( dartDoc: getCursorDocComment( cursor, nesting.length + commentPrefix.length, ), - originalName: cursor.spelling(), + originalName: spelling, name: config.structDecl.renameMemberUsingConfig( parsed.compound.originalName, - cursor.spelling(), + spelling, ), type: mt, ),