Skip to content

Fix missing namespaces in macros#1996

Open
FishermanWWK wants to merge 3 commits into
godotengine:masterfrom
FishermanWWK:master
Open

Fix missing namespaces in macros#1996
FishermanWWK wants to merge 3 commits into
godotengine:masterfrom
FishermanWWK:master

Conversation

@FishermanWWK
Copy link
Copy Markdown

Changed the method call to memnew_arr_template in the memnew_arr and the classes in the size validation macros for SafeNumeric and SafeFlag to use the full namespace path to their corresponding method / class. This ensures that if anyone is using these macros in their own code and they don't use using namespace godot; in their code, these macros will still compile.

memnew_arr was the issue I initially ran into, and I came across the SafeNumeric and SafeFlag macros while checking to see if any other macros had this problem. I also found the MAKE_TYPE_INFO* macros in type_info.hpp, as well as MAKE_TYPED_ARRAY and MAKE_TYPED_DICTIONARY* in typed_array.hpp and typed_dictionary.hpp respectively, however, these seemed to be internal macros only, so I've left them untouched since I didn't think anyone would be using these in their own projects (I thought that it might be possible for the SafeNumeric and SafeFlag macros to appear in other projects though, which is why I included them).

Added `::godot::*` to the method calls in some macros so that they work even if someone isn't using `using namespace godot`.
@FishermanWWK FishermanWWK requested a review from a team as a code owner June 1, 2026 17:10
Copy link
Copy Markdown
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the fix!

Copy link
Copy Markdown
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dsnopek
Copy link
Copy Markdown
Collaborator

dsnopek commented Jun 1, 2026

Ah, it looks like this is failing CI for some code style issues which would be fixed by this patch:

diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp
index 42b3b77..8dd97c3 100644
--- a/include/godot_cpp/templates/safe_refcount.hpp
+++ b/include/godot_cpp/templates/safe_refcount.hpp
@@ -48,11 +48,11 @@ namespace godot {
 //   even with threads that are already running.
 
 // These are used in very specific areas of the engine where it's critical that these guarantees are held
-#define SAFE_NUMERIC_TYPE_PUN_GUARANTEES(m_type)                    \
+#define SAFE_NUMERIC_TYPE_PUN_GUARANTEES(m_type)                             \
 	static_assert(sizeof(::godot::SafeNumeric<m_type>) == sizeof(m_type));   \
 	static_assert(alignof(::godot::SafeNumeric<m_type>) == alignof(m_type)); \
 	static_assert(std::is_trivially_destructible_v<std::atomic<m_type>>);
-#define SAFE_FLAG_TYPE_PUN_GUARANTEES                \
+#define SAFE_FLAG_TYPE_PUN_GUARANTEES                         \
 	static_assert(sizeof(::godot::SafeFlag) == sizeof(bool)); \

Added `::godot::*` to the method calls in some macros so that they work even if someone isn't using `using namespace godot`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants