rust-bindgen: "invalid identifier" when clang targets obj-c
Input Obj-C Header
//
// HapticIFace.h
// rusttest
//
// Created by user on 4/6/23.
//
#ifndef HapticIFace_h
#define HapticIFace_h
#import <CoreHaptics/CoreHaptics.h>
@interface HapticIFace : NSObject {
}
@property (nonatomic, strong) CHHapticEngine* engine;
@end
#endif /* HapticIFace_h */
This is here as a placeholder since it was the last file I tried. Any file causes this error.
Bindgen Invocation
bindgen ./HapticIFace.h -- -target arm64-apple-ios -x objective-c -isysroot /Users/user/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
Actual Results
panicked at 'Invalid identifier: Error("expected identifier")', /Users/user/.cargo/registry/src/github.com-x/bindgen-0.64.0/ir/objc.rs:272:30
Expected Results
Unknown
===
This error happens on all files I use w/ objective-c.
I mistakenly attached this onto issue #2029.
There, I’d used a premade command courtesy of @.simlay: https://simlay.net/posts/rust-bindgen-objc-support/#adding-a-build-rs . I modified it to the correct paths for my usecase and ran that build.rs using cargo and had the same issue.
Importantly, if I put a random file in, it goes through that file and obviously detects syntax errors. Perhaps the issue happening here comes after the file is processed? I ran with RUST_BACKTRACE=1 and there was no difference in the error message, and I also am currently running with RUST_LOG=bindgen. It’s been going for about fifteen minutes but it’s getting slower as more stuff gets printed. It’s definitely working with the code given, so I think whatever the issue is is happening after the ir is generated.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 16 (7 by maintainers)
Glad to hear it worked 😃
That seems to have fixed the issue for me!
It did indeed work 😄
@duckfromdiscord ohh sorry I closed it eagerly (I got excited about fixing it). Please reopen the issue if the fix did not work
A little more context, also running into this issue. It seems to be with parsing the name of some identifier named
self, which is not a valid identifier in Rust.The commit that broke it when I bisected was: https://github.com/rust-lang/rust-bindgen/commit/6e5a666507bb5f4611dc31ca2e11e73cb5ffdbd1