autocxx
autocxx copied to clipboard
Support C++ deprecated attribute to reduce warnings
I've got some C++ code that uses the deprecated attribute, say like this (renaming stuff for simplicity, so my apologies if the warning below is off):
[[deprecated( "foo is deprecated and will be removed in the next version." )]]
virtual int foo() = 0;
Autocxx then generates this code for it:
inline int foo_autocxx_wrapper_0x4c2f5dcd019b1af8(Bar& autocxx_gen_this) { return autocxx_gen_this.foo(); }
Then, when compiling, I get warnings such as this:
warning: [email protected]: In file included from /home/space/repos/export-server/target/debug/build/crate-sys-a317d4556f361b64/out/autocxx-build-dir/cxx/gen0.cxx:10:
warning: [email protected]: /home/space/repos/export-server/target/debug/build/crate-sys-a317d4556f361b64/out/autocxx-build-dir/include/autocxxgen_ffi.h: In function ‘int foo_autocxx_wrapper_0x4c2f5dcd019b1af8(Bar&)’:
warning: [email protected]: /home/space/repos/export-server/target/debug/build/crate-sys-a317d4556f361b64/out/autocxx-build-dir/include/autocxxgen_ffi.h:318:131: warning: ‘foo is deprecated and will be removed in the next version. [-Wdeprecated-declarations]
warning: [email protected]: 318 | inline int foo_autocxx_wrapper_0x4c2f5dcd019b1af8(Bar& autocxx_gen_this) { return autocxx_gen_this.foo(); }
warning: [email protected]: | ~~~~~~~~~~~~~~~~~~~~^~
...
Because the project I'm using this with has a lot of those functions, this generates a lot of noise and hides actual problems, whether I use the deprecated functions or not.
I suggest this behaviour instead:
- Suppress all existing warnings by disabling
deprecated-declarations - Annotate corresponding rust functions with
#[deprecated]and the given warning message
Then we should get warnings only when using the actually bad functionality in rust.
I like the idea and I'd be happy to accept a pull request!