Skip to content

No 'EntryPoint' attribute is generated for C++ mangled functions #245

@zeule

Description

@zeule

Given the following header:

namespace N {
   int f();
}

the generator fails to add mangled name to the DllImport attribute. Don't really know what am I doing, but the following change seems to make it work:

diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
index 097e5df..97bac12 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
@@ -464,10 +464,10 @@ namespace ClangSharp
             }
 
             var callingConventionName = GetCallingConvention(functionDecl, callConv, name);
-            var entryPoint = !isVirtual && body is null
-                ? (cxxMethodDecl is null) ? GetCursorName(functionDecl) : cxxMethodDecl.Handle.Mangling.CString
+            var isDllImport = !isVirtual && body is null;
+            var entryPoint = isDllImport
+                ? (cxxMethodDecl is null) ? functionDecl.Handle.Mangling.CString : cxxMethodDecl.Handle.Mangling.CString
                 : null;
-            var isDllImport = body is null && !isVirtual;
 
             var desc = new FunctionOrDelegateDesc<(string Name, PInvokeGenerator This)>
             {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions