Skip to content
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

Support C++ deprecated attribute to reduce warnings #1403

Open
ShaddyDC opened this issue Oct 22, 2024 · 1 comment
Open

Support C++ deprecated attribute to reduce warnings #1403

ShaddyDC opened this issue Oct 22, 2024 · 1 comment

Comments

@ShaddyDC
Copy link

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: crate-sys@0.1.0: In file included from /home/space/repos/export-server/target/debug/build/crate-sys-a317d4556f361b64/out/autocxx-build-dir/cxx/gen0.cxx:10:
warning: crate-sys@0.1.0: /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: crate-sys@0.1.0: /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: crate-sys@0.1.0:   318 | inline int foo_autocxx_wrapper_0x4c2f5dcd019b1af8(Bar& autocxx_gen_this)  { return autocxx_gen_this.foo(); }
warning: crate-sys@0.1.0:       |                                                                                    ~~~~~~~~~~~~~~~~~~~~^~
...

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:

  1. Suppress all existing warnings by disabling deprecated-declarations
  2. 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.

@adetaylor
Copy link
Collaborator

I like the idea and I'd be happy to accept a pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants