Skip to content

Fix missing namespaces in macros#1996

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
FishermanWWK:master
Jun 2, 2026
Merged

Fix missing namespaces in macros#1996
dsnopek merged 1 commit into
godotengine:masterfrom
FishermanWWK:master

Conversation

@FishermanWWK
Copy link
Copy Markdown
Contributor

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).

@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)); \

@Ivorforce
Copy link
Copy Markdown
Member

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

Reminds me: We should probably follow suit with godot (godotengine/godot#112381)

Changed some macros to use the full (`::godot::*`) namespace path to method calls and class names.
@FishermanWWK FishermanWWK reopened this Jun 2, 2026
@FishermanWWK
Copy link
Copy Markdown
Contributor Author

Should be fixed now (and I figured out how to run the checks on my branch, so it should actually work this time, sorry about that).

I'm also still relatively new to Git / Github, and I'm not sure if you got spammed with email notifications from me trying to fix the commit, I'm really sorry if you did.

@dsnopek
Copy link
Copy Markdown
Collaborator

dsnopek commented Jun 2, 2026

Thanks!

I'm also still relatively new to Git / Github, and I'm not sure if you got spammed with email notifications from me trying to fix the commit, I'm really sorry if you did.

No worries :-)

@dsnopek dsnopek added this to the 10.x milestone Jun 2, 2026
@dsnopek dsnopek added the bug This has been identified as a bug label Jun 2, 2026
@dsnopek dsnopek merged commit 5a7bd2f into godotengine:master Jun 2, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants