How do I bind a single C/C++ function with GDNative?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ipbv

I would like to use class independent C/C++ functions inside Godot but the example projects I could find only showed how to register methods belonging to a class? Even the C Example from the documentation works with a class. Does anyone know how to do this?

:bust_in_silhouette: Reply From: r.bailey

What are you looking to do with this class independent functions?

Out the box what it sounds like what you are trying to do won’t work without instancing through a class in GDnative or by changing the engine itself.

I don’t have a specific plan with this. It was more a general question because I found it a bit unnecessary having to create a multiplier object for example that just uses a multiplier function. So I was hoping to be able to avoid such patterns.

ipbv | 2021-10-31 17:06

Yeah, sadly to what I know you would have to create an class(object) and with that class you could create the functions and just call the functions on the class to do whatever you want. In GDNative there is no way around that, from what I have seen.

r.bailey | 2021-11-01 15:50