Fix missing namespaces in macros#1996
Open
FishermanWWK wants to merge 3 commits into
Open
Conversation
Added `::godot::*` to the method calls in some macros so that they work even if someone isn't using `using namespace godot`.
Ivorforce
approved these changes
Jun 1, 2026
Member
Ivorforce
left a comment
There was a problem hiding this comment.
Makes sense, thanks for the fix!
Collaborator
|
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changed the method call to
memnew_arr_templatein thememnew_arrand the classes in the size validation macros forSafeNumericandSafeFlagto 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 useusing namespace godot;in their code, these macros will still compile.memnew_arrwas the issue I initially ran into, and I came across theSafeNumericandSafeFlagmacros while checking to see if any other macros had this problem. I also found theMAKE_TYPE_INFO*macros in type_info.hpp, as well asMAKE_TYPED_ARRAYandMAKE_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 theSafeNumericandSafeFlagmacros to appear in other projects though, which is why I included them).