saucecontrol
saucecontrol
CC#
Created by Shoey on 7/18/2024 in #help
How can I use a precompiled C/C++ dll in a C# project?
reliant on pointers in a way that C# doesn't seem to support
this is unlikely. there may be some opaque pointer typedefs that don't translate cleanly, but you can just declare those as void* in C#. a pointer is a pointer at the ABI level
21 replies
CC#
Created by Shoey on 7/18/2024 in #help
How can I use a precompiled C/C++ dll in a C# project?
if you're shaky on the C side as well as the C# side, it can be tricky business, but if you know C reasonably well, it's pretty easy to make sure the bindings are compatible
21 replies
CC#
Created by Shoey on 7/18/2024 in #help
How can I use a precompiled C/C++ dll in a C# project?
WINAPI means StdCall calling convention in C#, which is the default in Windows, so you can leave out calling convention if that's what your C DLL defines and you only care about Windows. all you need for a proper DllImport declaration is to use compatible C# types for all args to the function. the easiest way to generate compatible declarations these days is to use https://www.nuget.org/packages/ClangSharpPInvokeGenerator you point the generator app at your library's .h file, and it will create C# bindings for you.
21 replies