Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
jonathan-rizk edited this page Apr 18, 2020 · 2 revisions

Welcome to the OWTP wiki!

Interop

C is able to interoperate with many languages. This section is intended to provide a few examples of how to use the library with some popular languages.

C# Interop

I prefer to use static classes to organize external functions that I want to use. This class will import the function that returns the specific volume, given pressure and temperature.

ImportedFunctions.cs

using System.Runtime.InteropServices;

namespace MyProject
{
    public static class ImportedFunctions
    {
        [DllImport(@"OWTP.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern double v_P_T(double P, double T);
    }
}

You may then use the function like this

MyClass.cs

using System.Diagnostics;

namespace MyProject
{
    public static class MyClass
    {
        public static void DoSomething(double P, double T)
        {
            double myDouble = ImportedFunctions(P,T);
            Debug.Print($"The specific volume is {myDouble.ToString()} m^3/kg.");
        }
    }
}
Clone this wiki locally