【发布时间】:2021-08-02 17:35:15
【问题描述】:
最近发布了 Visual Studio 2019 版本 16.9.5。它显然引入了新的警告:
[[nodiscard]] __declspec(dllexport) bool foo(); //ok
__declspec(dllexport) [[nodiscard]] bool bar(); // warning C5240: 'nodiscard': attribute is ignored in this syntactic position
其实我以为nodiscard和dllexport都是可以任意顺序出现的属性,还是不是?
【问题讨论】:
-
一个是标准的,另一个是特定于实现的。就任何规范而言,这里都没有真正的“正确”行为。作为一个 QoI 问题,我同意这是令人惊讶/令人烦恼的。
标签: c++ visual-studio-2019 warnings nodiscard