-
Notifications
You must be signed in to change notification settings - Fork 311
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
Implement volatile type qualifier #962
base: master
Are you sure you want to change the base?
Conversation
Btw, if you want I'm available to review+test+merge PRs that don't have merge conflicts, are not authored by me, and don't involve making releases. |
Hi, thanks for the PR! Do you know what the use case for tagging a type itself with So, not opposed to supporting stuff like: /// cbindgen:volatile
field: u32, Or so. But my other question is... Given rust doesn't support this qualifier at all, I'd expect consumers to deal with this the same way Rust would. E.g., when in rust you have:
In C++ you'd have something like: template <typename T>
T read_volatile(const T* ptr) {
return *((const volatile T*)ptr);
}
return read_volatile(&this->member); // Or so, or in C with a similar macro using typeof or what not Is there any reason something like that wouldn't work? It seems weird for cbindgen to transmit information that isn't on the rust code at all... |
I just tried to allow volatile in whatever places C allows. My use case is a conversion from C to rust, where a struct has a volatile variable. The volatile test shows what I think might be encountered in real code.
|
Also fixed the paths of globals not being mangled, discovered while testing the wrapper. |
Just in case it's not clear, this PR is ready for review. |
…ruct/union fields that have the `volatile` annotation.
Rebased to resolve merge conflicts. Still awaiting review. |
Emits the C volatile type qualifier for tranaprent that have the annotationcbindgen:volatile=true
.Emit C volatile type qualifier for transparent 1-field structs and struct/union fields that have the
volatile
annotation.Includes a mention in docs.md.
Includes test volatile.
Fixes #960
Fixes the paths of globals not being mangled.
I want to use this in public code so I would appreciate a release of cbindgen with this capability.
Pinging @emilio as the README mentions.