-
Notifications
You must be signed in to change notification settings - Fork 258
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
[BUG] sysroot/usr/include/amidi/AMidi.h is not valid C #1739
Comments
The enum underlying type also isn't standard C, but Clang accepts it without complaint. GCC rejects it, but we don't support GCC. Clang can diagnose this usage:
AFAIK Clang won't complain about a system header ( I think we're OK with this Clang dependency? I think this particular fixed type in AMidi.h is redundant, because the enum type would already be treated like it had a fixed type of 32-bit signed int. Not 100% sure about that though. |
Yes, this was an intentional change made by API council. You get much better diagnostics, IDE behavior, ABI tracking, etc if the APIs can use the enums directly rather than using |
When I originally reported this problem to @jfgoog I was using |
Looks like our guidelines were missing the "you need to use a typedef because C" for enums, though we had it for structs. I've sent a CL to fix the copy pasta landmines in the docs, and also the CL fixing this incorrect case. |
Is this enum and typedef code in AAudio.h OK? |
It's an older code, but it checks out. The change to the API guidelines to prefer use of the enum itself with a specified backing type is quite new, and aaudio predates that. aaudio.h will work just fine with C code. You could update the header to do: typedef enum aaudio_sharing_mode_t : int32_t {
...
} aaudio_sharing_mode_t; The new form has a lot of UX improvements. Most IDE features will work better if the function decls refer to the actual enum. It also will benefit the new ABI tracking tooling that we haven't deployed yet. We're not pushing anyone toward making those updates (yet), but feel free :) |
@philburk It's valid, but as @DanAlbert mentions these anonymous pub const AAUDIO_SHARING_MODE_EXCLUSIVE: ::std::os::raw::c_uint = 0;
pub const AAUDIO_SHARING_MODE_SHARED: ::std::os::raw::c_uint = 1;
pub type _bindgen_ty_50 = ::std::os::raw::c_uint;
pub type aaudio_sharing_mode_t = i32; For example, for impl AMidiDevice_Protocol {
pub const AMIDI_DEVICE_PROTOCOL_UMP_USE_MIDI_CI: AMidiDevice_Protocol = AMidiDevice_Protocol(0);
}
impl AMidiDevice_Protocol {
pub const AMIDI_DEVICE_PROTOCOL_UMP_MIDI_1_0_UP_TO_64_BITS: AMidiDevice_Protocol =
AMidiDevice_Protocol(1);
}
// ...
impl AMidiDevice_Protocol {
pub const AMIDI_DEVICE_PROTOCOL_UNKNOWN: AMidiDevice_Protocol = AMidiDevice_Protocol(-1);
}
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct AMidiDevice_Protocol(pub i32); And with some bindgen tweaking we might do even better (and there's a special representation for bitflags types as well). |
I hadn't actually thought about the problem from this angle before. Filed #1741 to track it. |
Finally has both the review it needs and has passed presubmit. We still need to manually pull the update into the NDK before it will be available in even a canary build. |
https://android-review.googlesource.com/q/project:platform/ndk+branch:master @DanAlbert where can we find the change? |
Nowhere until I pull that update. It had to land in an internal branch to avoid merge conflicts. |
https://android-review.googlesource.com/c/platform/prebuilts/ndk/+/2182695 has the updated sysroot. It's in presubmit right now but will make it into https://ci.android.com/builds/branches/aosp-master-ndk/grid? shortly after that merges. I'm going to get that (and a few other fixes) cherry-picked into r25b and send that off to QA soonish (a build should be visible in ci.android.com, but QA schedules are almost always the longest part of the release). |
Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#1739 Change-Id: Ia4485efe11862fcf1b8f6b8a2a7674f72748dd2a
Test: ndk/checkbuild.py && ndk/run_tests.py Bug: android/ndk#1739 Change-Id: Ia4485efe11862fcf1b8f6b8a2a7674f72748dd2a (cherry picked from commit d90e95c) Merged-In: Ia4485efe11862fcf1b8f6b8a2a7674f72748dd2a
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Bug: android/ndk#1739 Test: treehugger Change-Id: I1ab7fabeaa592a2c7011daddff8661bdc3950da1 Signed-off-by: Pranav Vashi <[email protected]>
Description
Offending code is: https://android.googlesource.com/platform/prebuilts/ndk/+blame/refs/heads/dev/platform/sysroot/usr/include/amidi/AMidi.h
Needs a typedef:
Or an enum here:
Affected versions
r25
Canary version
No response
Host OS
Linux, Mac, Windows
Host OS version
All
Affected ABIs
armeabi-v7a, arm64-v8a, x86, x86_64
Build system
Other (specify below)
Other build system
All
minSdkVersion
API was introduced in 33.
Device API level
All
The text was updated successfully, but these errors were encountered: