-
Notifications
You must be signed in to change notification settings - Fork 19
Usage
Gabriel edited this page Sep 26, 2023
·
3 revisions
To reference a library, you can use the #lib
preprocessor directive.
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.
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.
Code "Example Code" by "Hyper"
//
#lib "ExampleLibrary"
using EL = ExampleLibrary;
//
{
EL.MyFunction();
}
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.
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!");
}
- Home
- Codes
-
Libraries
- Getting started
- Features
-
Usage
- Static reference
- Include reference
- Global
- Sonic Frontiers
- Sonic Origins