Skip to content

Commit f737ad6

Browse files
committed
Fix the C++ printing of function pointers in parameters
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent ba31570 commit f737ad6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Generator/Generators/C/CppTypePrinter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,12 @@ public override TypePrinterResult VisitParameter(Parameter arg, bool hasName = t
337337
return printName ? string.Format(":({0}){1}", type, name)
338338
: string.Format(":({0})", type);
339339

340-
return printName ? string.Format("{0} {1}", type, name) : type;
340+
CppSharp.AST.Type desugared = arg.Type.Desugar();
341+
desugared = (desugared.GetFinalPointee() ?? desugared).Desugar();
342+
return printName ?
343+
((!(arg.Type is TypedefType) || ResolveTypedefs) &&
344+
desugared is FunctionType ?
345+
type.Replace("(*)", $"(*{name})") : $"{type} {name}") : type;
341346
}
342347

343348
public override TypePrinterResult VisitDelegate(FunctionType function)

0 commit comments

Comments
 (0)