Skip to content
Gabriel edited this page Sep 26, 2023 · 3 revisions

Table of contents

Static reference

To reference a library, you can use the #lib preprocessor directive.

Examples

Library "ExampleLibrary" by "Hyper"
{
    public void MyFunction()
    {
        Console.WriteLine("Hello world!");
    }
}

Code "Example Code" by "Hyper"
//
    #lib "ExampleLibrary"
//
{
    ExampleLibrary.MyFunction();
}

You can also avoid constantly writing the library's class name by using #import instead of #lib, which will automatically create a static using directive.

Examples

Code "Example Code" by "Hyper"
//
    #import "ExampleLibrary"
//
{
    MyFunction();
}

Although, this is only recommended for libraries that don't have conflicting members, as two libraries containing members with identical names may conflict. To work around this, you can create aliases instead.

Examples

Code "Example Code" by "Hyper"
//
    #lib "ExampleLibrary"

    using EL = ExampleLibrary;
//
{
    EL.MyFunction();
}

Include reference

If your library contains macros, you can bring them over by using the #include preprocessor directive. This works just like it does in C/C++, it copies all of the code within the library scope into your code instead of using a reference.

Examples

Library "ExampleLibrary" by "Hyper"
{
    #define EXAMPLE(in_str) MyFunction(in_str)

    public void MyFunction(string in_str)
    {
        Console.WriteLine(in_str);
    }
}

Code "Example Code" by "Hyper"
//
    #include "ExampleLibrary" noemit
//
{
    EXAMPLE("Hello world!");
}
Clone this wiki locally