How to prevent unused variable warnings in static_assert?

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5713
Joined: Mon Apr 10, 2017 4:25 pm

How to prevent unused variable warnings in static_assert?

#1 Post by Oberlus »

From https://github.com/freeorion/freeorion/ ... bjectMap.h

Code: Select all

constexpr bool invokable = invoke_flags[8];

if constexpr (is_int_range) {
    // ...
} else {
    static_assert(invokable, "Don't know how to handle predicate");
}
I've tried adding "((void)(invokable))", or "invokable=invokable", after static_assert(), and I see no changes in compilation warnings (and no errors).
I've also tried adding "[[maybe_unused]]" before "constexpr bool invokable". No changes.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: How to prevent unused variable warnings in static_assert?

#2 Post by Geoff the Medio »


User avatar
Oberlus
Cosmic Dragon
Posts: 5713
Joined: Mon Apr 10, 2017 4:25 pm

Re: How to prevent unused variable warnings in static_assert?

#3 Post by Oberlus »

Great! Thank you.

Post Reply