Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,19 @@ private void VisitIndirectFieldDecl(IndirectFieldDecl indirectFieldDecl)
var accessSpecifier = GetAccessSpecifier(anonymousRecordDecl, matchStar: true);

var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out _);

if (!_config.GenerateDisableRuntimeMarshalling && typeName.Equals("bool", StringComparison.Ordinal))
{
// bool is not blittable when DisableRuntimeMarshalling is not specified, so we shouldn't use it for structs that may be in P/Invoke signatures
typeName = "byte";
}

if (_config.GenerateCompatibleCode && typeName.StartsWith("bool*", StringComparison.Ordinal))
{
// bool* is not blittable in compat mode, so we shouldn't use it for structs that may be in P/Invoke signatures
typeName = typeName.Replace("bool*", "byte*", StringComparison.Ordinal);
}

var name = GetRemappedCursorName(fieldDecl);
var escapedName = EscapeName(name);

Expand Down