I wanted to use Nim inside my C# code, and I used this https://www.euantorano.co.uk/posts/nim-with-c-sharp-net/ example with no issue. Okay I said, lets get a string proc working.
proc HelloNim*(a, b: cint): cstring {.cdecl, exportc, dynlib.} =
return "bob".cstring
then in C#
using System;
using System.Runtime.InteropServices;
namespace Miasma
{
class Program
{
static void Main(string[] args)
{
string b = ""+HelloNim(1,2);
Console.WriteLine(b);
}
[DllImport("HelloNim.dll")]
public static extern void NimMain();
[DllImport("HelloNim.dll")]
public static extern string HelloNim(int a, int b);
}
}
This does not error, but it doesn't print out any string either. Lorks. What has gone wrong?