From f93a4287cf833134020e5b35c4b800c2edff1b94 Mon Sep 17 00:00:00 2001 From: Ninni Pipping Date: Thu, 11 May 2023 12:32:23 +0200 Subject: Enable shadow warnings and fix raised errors (cherry picked from commit 71ee65dc5701a0675ae6b1879a694a28c7206a63) --- platform/ios/ios.mm | 18 +++++++++--------- platform/linuxbsd/x11/detect_prime_x11.cpp | 3 +++ platform/linuxbsd/x11/display_server_x11.cpp | 22 +++++++++++----------- platform/linuxbsd/x11/display_server_x11.h | 2 +- platform/linuxbsd/x11/gl_manager_x11.cpp | 3 +++ platform/macos/display_server_macos.mm | 10 +++++----- platform/windows/os_windows.cpp | 14 ++++++-------- 7 files changed, 38 insertions(+), 34 deletions(-) (limited to 'platform') diff --git a/platform/ios/ios.mm b/platform/ios/ios.mm index d240891a5c..93bf45f0b9 100644 --- a/platform/ios/ios.mm +++ b/platform/ios/ios.mm @@ -72,8 +72,8 @@ CHHapticEngine *iOS::get_haptic_engine_instance() API_AVAILABLE(ios(13)) { void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) { if (@available(iOS 13, *)) { // We need the @available check every time to make the compiler happy... if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { NSDictionary *hapticDict = @{ CHHapticPatternKeyPattern : @[ @{CHHapticPatternKeyEvent : @{ @@ -88,7 +88,7 @@ void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) NSError *error; CHHapticPattern *pattern = [[CHHapticPattern alloc] initWithDictionary:hapticDict error:&error]; - [[haptic_engine createPlayerWithPattern:pattern error:&error] startAtTime:0 error:&error]; + [[cur_haptic_engine createPlayerWithPattern:pattern error:&error] startAtTime:0 error:&error]; NSLog(@"Could not vibrate using haptic engine: %@", error); } @@ -103,9 +103,9 @@ void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) void iOS::start_haptic_engine() { if (@available(iOS 13, *)) { if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { - [haptic_engine startWithCompletionHandler:^(NSError *returnedError) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { + [cur_haptic_engine startWithCompletionHandler:^(NSError *returnedError) { if (returnedError) { NSLog(@"Could not start haptic engine: %@", returnedError); } @@ -122,9 +122,9 @@ void iOS::start_haptic_engine() { void iOS::stop_haptic_engine() { if (@available(iOS 13, *)) { if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { - [haptic_engine stopWithCompletionHandler:^(NSError *returnedError) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { + [cur_haptic_engine stopWithCompletionHandler:^(NSError *returnedError) { if (returnedError) { NSLog(@"Could not stop haptic engine: %@", returnedError); } diff --git a/platform/linuxbsd/x11/detect_prime_x11.cpp b/platform/linuxbsd/x11/detect_prime_x11.cpp index 3d07be1c76..78778a8b56 100644 --- a/platform/linuxbsd/x11/detect_prime_x11.cpp +++ b/platform/linuxbsd/x11/detect_prime_x11.cpp @@ -60,6 +60,9 @@ typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *); +// To prevent shadowing warnings +#undef glGetString + struct vendor { const char *glxvendor = nullptr; int priority = 0; diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index d70efb53f8..7f7a2bcfcd 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -2710,8 +2710,8 @@ void DisplayServerX11::cursor_set_custom_image(const Ref &p_cursor, Cu XcursorImageDestroy(cursor_image); } else { // Reset to default system cursor - if (img[p_shape]) { - cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]); + if (cursor_img[p_shape]) { + cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_img[p_shape]); } CursorShape c = current_cursor; @@ -5319,7 +5319,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode for (int i = 0; i < CURSOR_MAX; i++) { cursors[i] = None; - img[i] = nullptr; + cursor_img[i] = nullptr; } XInitThreads(); //always use threads @@ -5611,8 +5611,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode "question_arrow" }; - img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); - if (!img[i]) { + cursor_img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); + if (!cursor_img[i]) { const char *fallback = nullptr; switch (i) { @@ -5650,7 +5650,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode fallback = "bd_double_arrow"; break; case CURSOR_MOVE: - img[i] = img[CURSOR_DRAG]; + cursor_img[i] = cursor_img[CURSOR_DRAG]; break; case CURSOR_VSPLIT: fallback = "sb_v_double_arrow"; @@ -5663,11 +5663,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode break; } if (fallback != nullptr) { - img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size); + cursor_img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size); } } - if (img[i]) { - cursors[i] = XcursorImageLoadCursor(x11_display, img[i]); + if (cursor_img[i]) { + cursors[i] = XcursorImageLoadCursor(x11_display, cursor_img[i]); } else { print_verbose("Failed loading custom cursor: " + String(cursor_file[i])); } @@ -5806,8 +5806,8 @@ DisplayServerX11::~DisplayServerX11() { if (cursors[i] != None) { XFreeCursor(x11_display, cursors[i]); } - if (img[i] != nullptr) { - XcursorImageDestroy(img[i]); + if (cursor_img[i] != nullptr) { + XcursorImageDestroy(cursor_img[i]); } } diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h index dbe8a0ce2b..c0fae38874 100644 --- a/platform/linuxbsd/x11/display_server_x11.h +++ b/platform/linuxbsd/x11/display_server_x11.h @@ -305,7 +305,7 @@ class DisplayServerX11 : public DisplayServer { const char *cursor_theme = nullptr; int cursor_size = 0; - XcursorImage *img[CURSOR_MAX]; + XcursorImage *cursor_img[CURSOR_MAX]; Cursor cursors[CURSOR_MAX]; Cursor null_cursor; CursorShape current_cursor = CURSOR_ARROW; diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index ee767dfa80..1e579c9f01 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -44,6 +44,9 @@ typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *); +// To prevent shadowing warnings +#undef glXCreateContextAttribsARB + struct GLManager_X11_Private { ::GLXContext glx_context; }; diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 2d0335f95a..95d9e32e17 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -1839,9 +1839,9 @@ Error DisplayServerMacOS::dialog_show(String p_title, String p_description, Vect if (!p_callback.is_null()) { Variant button = button_pressed; Variant *buttonp = &button; - Variant ret; + Variant fun_ret; Callable::CallError ce; - p_callback.callp((const Variant **)&buttonp, 1, ret, ce); + p_callback.callp((const Variant **)&buttonp, 1, fun_ret, ce); } return OK; @@ -1871,9 +1871,9 @@ Error DisplayServerMacOS::dialog_input_text(String p_title, String p_description if (!p_callback.is_null()) { Variant text = ret; Variant *textp = &text; - Variant ret; + Variant fun_ret; Callable::CallError ce; - p_callback.callp((const Variant **)&textp, 1, ret, ce); + p_callback.callp((const Variant **)&textp, 1, fun_ret, ce); } return OK; @@ -1896,7 +1896,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) { bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED); if (show_cursor && !previously_shown) { - WindowID window_id = get_window_at_screen_position(mouse_get_position()); + window_id = get_window_at_screen_position(mouse_get_position()); if (window_id != INVALID_WINDOW_ID) { send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 66b7d1284e..4ac76a5179 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -339,8 +339,6 @@ String OS_Windows::get_distribution_name() const { } String OS_Windows::get_version() const { - typedef LONG NTSTATUS; - typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion"); if (version_ptr != nullptr) { RTL_OSVERSIONINFOW fow; @@ -458,9 +456,9 @@ OS::DateTime OS_Windows::get_datetime(bool p_utc) const { //Get DST information from Windows, but only if p_utc is false. TIME_ZONE_INFORMATION info; - bool daylight = false; + bool is_daylight = false; if (!p_utc && GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { - daylight = true; + is_daylight = true; } DateTime dt; @@ -471,20 +469,20 @@ OS::DateTime OS_Windows::get_datetime(bool p_utc) const { dt.hour = systemtime.wHour; dt.minute = systemtime.wMinute; dt.second = systemtime.wSecond; - dt.dst = daylight; + dt.dst = is_daylight; return dt; } OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { TIME_ZONE_INFORMATION info; - bool daylight = false; + bool is_daylight = false; if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { - daylight = true; + is_daylight = true; } // Daylight Bias needs to be added to the bias if DST is in effect, or else it will not properly update. TimeZoneInfo ret; - if (daylight) { + if (is_daylight) { ret.name = info.DaylightName; ret.bias = info.Bias + info.DaylightBias; } else { -- cgit v1.2.3