Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような意味のあるアサートを作成したかったのです。
assert(("precondition failed", false));
そして、それはGCCの下で正常に機能しましたが、Clangは未使用の値、 value について警告します"precondition failed"。
"precondition failed"
コードでこの警告を無効にする方法を知っていますか (コマンドライン引数や移植性のないコードは使用しないでください)。アサートを書き直すことも良い答えです。
を使用しても警告を生成しない 2 つの方法を次に示します-Wall -Wextra pedantic。
-Wall -Wextra pedantic
assert(((void)"precondition failed", false)); // #1 assert("precondition failed" && false); // #2