From 9c0bd332a5a6cd574807f64bb56964e8ffa5c4f8 Mon Sep 17 00:00:00 2001 From: Caroline Joy Bell Date: Tue, 16 Jan 2024 14:16:47 -0600 Subject: [PATCH] Fix `#if *_ENABLED` inconsistencies, should check if defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: RĂ©mi Verschelde --- drivers/coreaudio/audio_driver_coreaudio.h | 6 +++--- drivers/gles2/rasterizer_scene_gles2.cpp | 8 ++++---- drivers/gles2/rasterizer_storage_gles2.cpp | 6 +++--- main/main_builders.py | 4 ++-- modules/mono/csharp_script.cpp | 4 ++-- modules/mono/mono_gd/gd_mono_internals.cpp | 2 +- modules/mono/utils/path_utils.cpp | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h index ab1aa28b90a..7c5f8abe11d 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -28,11 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifdef COREAUDIO_ENABLED - #ifndef AUDIO_DRIVER_COREAUDIO_H #define AUDIO_DRIVER_COREAUDIO_H +#ifdef COREAUDIO_ENABLED + #include "servers/audio_server.h" #include @@ -120,6 +120,6 @@ public: ~AudioDriverCoreAudio(); }; -#endif +#endif // COREAUDIO_ENABLED #endif // AUDIO_DRIVER_COREAUDIO_H diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 08a45242853..c8dfb1e49cf 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -2840,7 +2840,7 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -#elif IPHONE_ENABLED +#elif defined(IPHONE_ENABLED) glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, next_buffer); @@ -2848,7 +2848,7 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -#elif ANDROID_ENABLED +#elif defined(ANDROID_ENABLED) // In GLES2 Android Blit is not available, so just copy color texture manually _copy_texture_to_buffer(storage->frame.current_rt->multisample_color, next_buffer); @@ -3579,7 +3579,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -#elif IPHONE_ENABLED +#elif defined(IPHONE_ENABLED) glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->multisample_fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->fbo); @@ -3587,7 +3587,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); -#elif ANDROID_ENABLED +#elif defined(ANDROID_ENABLED) // In GLES2 AndroidBlit is not available, so just copy color texture manually _copy_texture_to_buffer(storage->frame.current_rt->multisample_color, storage->frame.current_rt->fbo); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 11d8fd815f7..38b72a30648 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -5237,7 +5237,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, color_internal_format, rt->width, rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rt->multisample_color); -#elif ANDROID_ENABLED +#elif defined(ANDROID_ENABLED) // Render to a texture in android glGenTextures(1, &rt->multisample_color); glBindTexture(GL_TEXTURE_2D, rt->multisample_color); @@ -5639,7 +5639,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar t->alloc_width = rt->height; // Switch our texture on our frame buffer -#if ANDROID_ENABLED +#ifdef ANDROID_ENABLED if (rt->msaa >= VS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= VS::VIEWPORT_MSAA_EXT_4X) { // This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature // of the GPU we can do a single render pass by rendering directly into our texture chains @@ -6376,7 +6376,7 @@ void RasterizerStorageGLES2::initialize() { //void *gles2_lib = dlopen(NULL, RTLD_LAZY); //glRenderbufferStorageMultisampleAPPLE = dlsym(gles2_lib, "glRenderbufferStorageMultisampleAPPLE"); //glResolveMultisampleFramebufferAPPLE = dlsym(gles2_lib, "glResolveMultisampleFramebufferAPPLE"); -#elif ANDROID_ENABLED +#elif defined(ANDROID_ENABLED) void *gles2_lib = dlopen("libGLESv2.so", RTLD_LAZY); glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)dlsym(gles2_lib, "glRenderbufferStorageMultisampleEXT"); diff --git a/main/main_builders.py b/main/main_builders.py index 6e5a5ceede4..4905f0b7f28 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -105,10 +105,10 @@ def make_default_controller_mappings(target, source, env): platform_mappings[current_platform][guid] = line platform_variables = { - "Linux": "#if X11_ENABLED", + "Linux": "#ifdef X11_ENABLED", "Windows": "#ifdef WINDOWS_ENABLED", "Mac OS X": "#ifdef OSX_ENABLED", - "Android": "#if defined(__ANDROID__)", + "Android": "#ifdef ANDROID_ENABLED", "iOS": "#ifdef IPHONE_ENABLED", "Javascript": "#ifdef JAVASCRIPT_ENABLED", "UWP": "#ifdef UWP_ENABLED", diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index b400539d9c6..fa041f4cba8 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2833,7 +2833,7 @@ void CSharpScript::initialize_for_managed_type(Ref p_script, GDMon p_script->tool = nesting_class && nesting_class->has_attribute(CACHED_CLASS(ToolAttribute)); } -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED if (!p_script->tool) { p_script->tool = p_script->script_class->get_assembly() == GDMono::get_singleton()->get_tools_assembly(); } @@ -3174,7 +3174,7 @@ Error CSharpScript::reload(bool p_keep_state) { tool = nesting_class && nesting_class->has_attribute(CACHED_CLASS(ToolAttribute)); } -#if TOOLS_ENABLED +#ifdef TOOLS_ENABLED if (!tool) { tool = script_class->get_assembly() == GDMono::get_singleton()->get_tools_assembly(); } diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 67c0841ef93..4d2209ccec8 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -140,7 +140,7 @@ void gd_unhandled_exception_event(MonoException *p_exc) { mono_runtime_invoke(unhandled_exception_method, nullptr, (void **)args, nullptr); } -#if DEBUG_ENABLED +#ifdef DEBUG_ENABLED static String _get_var_type(const Variant *p_var) { String basestr; diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 77820a53f25..1c04de6fd23 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -133,7 +133,7 @@ String realpath(const String &p_path) { ::CloseHandle(hFile); return buffer.simplify_path(); -#elif UNIX_ENABLED +#elif defined(UNIX_ENABLED) char *resolved_path = ::realpath(p_path.utf8().get_data(), NULL); if (!resolved_path)