-
Notifications
You must be signed in to change notification settings - Fork 564
[C++] fix a handful of compiler warnings #5068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fa6e2b6 to
be54b24
Compare
Context: dotnet/java-interop#703 This commit fixes a handful of warnings reported by GCC and clang when building for different platforms. monodroid-glue.cc:1609:8: warning: declaration shadows a static data member of 'xamarin::android::internal::MonodroidRuntime' [-Wshadow] void *api_dso_handle = nullptr; ^ monodroid-glue.cc:102:25: note: previous declaration is here void *MonodroidRuntime::api_dso_handle = nullptr; Fix by renaming the local variable. No functionality changes result from this fix. MinGW builds report: xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state(const char*, mono_bool*)’: xa-internal-api.cc:24:86: warning: unused parameter ‘ifname’ [-Wunused-parameter] 24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) | ~~~~~~~~~~~~^~~~~~ xa-internal-api.cc:24:105: warning: unused parameter ‘is_up’ [-Wunused-parameter] 24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) | ~~~~~~~~~~~^~~~~ xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast(const char*, mono_bool*)’: xa-internal-api.cc:34:96: warning: unused parameter ‘ifname’ [-Wunused-parameter] 34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) | ~~~~~~~~~~~~^~~~~~ xa-internal-api.cc:34:115: warning: unused parameter ‘supports_multicast’ [-Wunused-parameter] 34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers(void**)’: xa-internal-api.cc:44:66: warning: unused parameter ‘dns_servers_array’ [-Wunused-parameter] 44 | MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers (void **dns_servers_array) | ~~~~~~~^~~~~~~~~~~~~~~~~ xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_getifaddrs(_monodroid_ifaddrs**)’: xa-internal-api.cc:54:82: warning: unused parameter ‘ifap’ [-Wunused-parameter] 54 | MonoAndroidInternalCalls_Impl::monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ xa-internal-api.cc: In member function ‘virtual void xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs(_monodroid_ifaddrs*)’: xa-internal-api.cc:64:82: warning: unused parameter ‘ifa’ [-Wunused-parameter] 64 | MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs (struct _monodroid_ifaddrs *ifa) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ The fix is to ignore the unused parameters only during Windows builds by using the C++17 attribute `[[maybe_unused]]` Another Windows-only warning: embedded-assemblies.cc: In static member function ‘static ssize_t xamarin::android::internal::EmbeddedAssemblies::do_read(int, void*, size_t)’: embedded-assemblies.cc:663:26: warning: conversion from ‘size_t’ {aka ‘long long unsigned int’} to ‘unsigned int’ may change value [-Wconversion] 663 | ret = ::read (fd, buf, count); | It is caused by `read(2)` declared in MinGW headers with the third parameter using `unsigned int` type instead of the standard `size_t`. Fixed by casting properly on Windows builds.
be54b24 to
233500f
Compare
| <PackageReference Include="System.Runtime" Version="4.3.1" /> | ||
| <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> | ||
| <PackageReference Include="XliffTasks" Version="1.0.0-beta.19252.1" PrivateAssets="all" /> | ||
| <PackageReference Include="XliffTasks" Version="1.0.0-beta.20206.1" PrivateAssets="all" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this was updated in the context of C++ warning removal…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the PR updates the Java.Interop submodule, whose master branch uses this version of XliffTasks and the difference in versions broke the build of XA with:
Installing System.Reflection.Emit.ILGeneration 4.3.0.
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Detected package downgrade: XliffTasks from 1.0.0-beta.20206.1 to 1.0.0-beta.19252.1. Reference the package directly from the project to select a different version. [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Xamarin.Android.Build.Tasks -> Java.Interop.Tools.Cecil -> Java.Interop.Localization -> XliffTasks (>= 1.0.0-beta.20206.1) [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Xamarin.Android.Build.Tasks -> XliffTasks (>= 1.0.0-beta.19252.1) [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Detected package downgrade: XliffTasks from 1.0.0-beta.20206.1 to 1.0.0-beta.19252.1. Reference the package directly from the project to select a different version. [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Xamarin.Android.Build.Tasks -> Java.Interop.Tools.JavaCallableWrappers -> Java.Interop.Localization -> XliffTasks (>= 1.0.0-beta.20206.1) [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/Current/bin/NuGet.targets(128,5): error : Xamarin.Android.Build.Tasks -> XliffTasks (>= 1.0.0-beta.19252.1) [/home/grendel/vc/xamarin/xamarin-android-worktrees/warnings-go-away/Xamarin.Android.sln]
Also, https://discordapp.com/channels/732297728826277939/732297837953679412/750350008464965632
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Context: dotnet/java-interop#703
This commit fixes a handful of warnings reported by GCC and clang when
building for different platforms.
Fix by renaming the local variable. No functionality changes result
from this fix.
MinGW builds report:
The fix is to ignore the unused parameters only during Windows builds
by using the C++17 attribute
[[maybe_unused]]Another Windows-only warning:
It is caused by
read(2)declared in MinGW headers with the thirdparameter using
unsigned inttype instead of the standardsize_t.Fixed by casting properly on Windows builds.