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

Warnings emitted by -Wdeprecated-redundant-constexpr-static-def #7794

Open
giesmininkas opened this issue Nov 12, 2024 · 1 comment
Open

Comments

@giesmininkas
Copy link

Please provide the following information

libtorrent version (or branch): 2.0.10
platform/architecture: x86_64 GNU/Linux
compiler and compiler version: clang-19 w/ libc++-19

Clang check -Wdeprecated-redundant-constexpr-static-def, when compiling in C++17 or greater, emits many warnings, such as:

libtorrent-src/src/alert.cpp:72:36: warning: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Wdeprecated-redundant-constexpr-static-def]
   72 |         constexpr alert_category_t alert::error_notification;
      |                                           ^

The warnings could be easily silenced by checking the __cplusplus preprocessor macro:

#if __cplusplus < 201703L
// define constexpr static data members
#endif

I can submit a patch if needed.

Thank you!

@arvidn
Copy link
Owner

arvidn commented Jan 25, 2025

Sure, a patch would be welcome. There's a risk, however, that __cplusplus won't be accurate enough. Also, I'm under the impression that you would need to rely in inline variables, by marking the declarations as inline in the header file. This is what I did in the master branch, which requires C++17 or later.

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