Skip to content
This repository was archived by the owner on Jul 13, 2024. It is now read-only.
This repository was archived by the owner on Jul 13, 2024. It is now read-only.

TraceLog fails with RuntimeError: null function or function signature mismatch #11

Description

@stanoddly

I found that LoadingVox example doesn't work, it kabooms on the TraceLog function call:

TraceLog(TraceLogLevel.LOG_WARNING, $"[{voxFileNames[i]}] File loaded in {t1 - t0} ms");
INFO: RLGL: Default OpenGL state initialized successfully
dotnet.js:14 INFO: TEXTURE: [ID 11] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
dotnet.js:14 INFO: FONT: Default font loaded successfully (224 glyphs)
dotnet.js:14 INFO: FILEIO: [resources/models/vox/chr_knight.vox] File loaded successfully
dotnet.js:14 INFO: MODEL: [resources/models/vox/chr_knight.vox] VOX data loaded successfully : 2920 vertices/1 meshes
dotnet.js:14 INFO: VAO: [ID 12] Mesh uploaded successfully to VRAM (GPU)
dotnet.js:5 RuntimeError: null function or function signature mismatch

            ^^^ HERE is kaboom if you are blind or drunk

I suspect that the DllImport in Raylib-cs isn't correct. It does this:

public static extern void TraceLog(TraceLogLevel logLevel, sbyte* text);

because the TraceLog in raylib is a variadic function:

void TraceLog(int logType, const char *text, ...)

https://github.com/raysan5/raylib/blob/dbdfad7ace061931da701070c5c7fbe772c57725/src/utils.c#L107

And these two will never be good friends. 🤔

Anyway this random internet guy found that __arglist does the trick:
https://www.c-sharpcorner.com/UploadFile/b942f9/calling-unmanaged-functions-which-take-a-variable-number-of-arguments-from-C-Sharp/

What the fawk is __arglist, the totally secret C# thing?!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug with workaround which needs to be resolved anyway.workaround existsWorkaround exists.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions