Godot Version
4.4.1
Question
I’m trying to build a test GDextension following the documentation on GDextension
I’ve followed the documentation to setup the project and I have the files:
test.cpp:
#include "test.h"
#include <godot_cpp/core/print_string.hpp>
using namespace godot;
Test::Test()
{
printf("TESTING STRING!\n");
print_line("Hello World!\n");
//UtilityFunctions::print("Hello World!\n");
}
Test::~Test()
{
}
void Test::_bind_methods()
{
}
test.h:
#ifndef TEST_CLASS_H
#define TEST_CLASS_H
#include <godot_cpp/classes/ref.hpp>
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
class Test : public RefCounted
{
GDCLASS(Test, RefCounted);
protected:
static void _bind_methods();
public:
Test();
~Test();
};
#endif // TEST_CLASS_H
And the corresponding register_types.c and register_types.h, I won’t post here because the extension builds and loads fine, so I don’t think the error is there.
My problem is that when I try to load and run the extension on a script using:
extends Node
func _ready() -> void:
var _test = Test.new()
(this is connected to a node in the scene)
the game just dies and on the console I get:
TESTING STRING!
*** stack smashing detected ***: terminated
so the first printf is working as expected, and the print on the godot console is running me on a buffer overflow of some sort, and this happens when I try to use print_line(“Hello World!\n”) or UtilityFunctions::print(“Hello World!\n”) directly, as the former is just a wrapper for the latter.
I did try to include the headers
#include <godot_cpp/variant/utility_functions.hpp>
#include <godot_cpp/variant/print_string.hpp>
or #include <godot_cpp/core/print_string.hpp>
All of them resulted in the same error, so I think it’s just an error on UtilityFunctions::print ? Has anyone ran into anything similar? Am I doing something wrong here?