#ifndef GODOT_STATIC_DELETER_H
#define GODOT_STATIC_DELETER_H
#include <godot_cpp/core/memory.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
namespace godot {
template <typename T>
struct Godot_Static_Deleter {
void operator()(T* ptr) const {
memdelete(ptr);
UtilityFunctions::print(String::utf8("静态变量删除成功"));
}
};
}
#endif
// I encountered a problem while writing C++ with GDExtension in Godot 4.4. Why isn't 'memdelete' highlighted, but AI says this is the correct way to use it? What's the actual situation, and how should I correctly release Godot pointers?
1 - what am I looking at?
2 -
I assume you are using an IDE? not that it’s needed, I code in what’s essentially notepad. but you won’t get highlight unless the entire project is loaded.
3 -
advice about AI: it lies, it is wrong, it is stupid. don’t trust anything that comes out of AI. don’t trust anything that comes out of AI when it comes to code.
4 - I can’t tell from a single look, but there is so much that seems off about this code.
why are you using a struct? and don’t structs need a variable at the end?
does this code compile?