- Edited
Just like doing a print() from GDScript I would like to print a message from C-code to the output of the Godot editor. As I understood I could use the Godot API for this.
I found the method "godot_print" in this file of godot_headers: In file "godot_headers/nativescript/gdnative_api.json". This is the definition I found:
{
"name": "godot_print",
"return_type": "void",
"arguments": [
["const godot_string *", "p_message"]
]
}
My main problem is how to define a "const godot_string *" in the C-file? And after that: How to call api->godot_print() with this string?
I've tried to define the string like this:
const godot_string *cdata = "my output message";
And the compiler gives me this warning:
src/simple.c:109:22: warning: incompatible pointer types initializing 'const godot_string *' with an expression of type 'char [18]' [-Wincompatible-pointer-types]
Then I've tried it like this:
const char *output = "my output message";
const godot_string *cdata = (const godot_string *)output;
This works without a warning.
Now when I use the string in the function call:
api->godot_print(cdata);
Godot editor crashes when building the project.