Skip to content

How do I export a function with a Callback argument for use in c? NativeAOT #69328

@insinfo

Description

@insinfo

How do I export a function with a Callback argument for use in c? I'm compiled with .NET 7 NativeAOT

using System;
using System.Runtime.InteropServices;

namespace classLib;
public class ClassLib
{
    [UnmanagedCallersOnly(EntryPoint = "add")]
    public static int Add(int a, int b, void (*func)() callback ){
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions