Skip to content

GDVIRTUAL macros are missing godot:: on METHOD_FLAG_VIRTUAL #1925

@ixvari

Description

@ixvari

Godot version

4.6

godot-cpp version

4.5

System information

Linux - CachyOS LTS Kernel

Issue description

If you try to use the GDVIRTUAL functions (such as GDVIRTUAL0 or GDVIRTUAL0R) without "using namespace godot;" at the top of your file, they will fail to compile. If I expand the macro inline this seems to be due to the the line:
method_info.flags = METHOD_FLAG_VIRTUAL;\
If I change this inline to:
method_info.flags = godot::METHOD_FLAG_VIRTUAL;\
Then everything begins to compile fine without the "using namespace godot;" at the top of my .hpp file. This seems to apply to all GDVIRTUAL macros

Steps to reproduce

Setup a gdextension project with the godot cpp bindings
Create a class and add a virtual function through GDVIRTUAL0 (or any virtual macro)
Add the bind_methods for it
This will result in scons failing to build the class

Minimal reproduction project

N/A However, here is a simple .hpp file to reproduce the issue

#pragma once

#include <godot_cpp/classes/node.hpp>
#include <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/core/gdvirtual.gen.inc>

//using namespace godot;

namespace Test
{
	class TestClass : public godot::Node {
	    	GDCLASS(TestClass, godot::Node)

		//Section for const private vars
		protected:
			GDVIRTUAL0(_TestFunction);
	};
}

Uncommenting the using namespace godot line will get rid of the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions