9

我正在做 Vulkan 教程 https://vulkan-tutorial.com/

#define GLFW_INCLUE_VULKAN
#include<GLFW/glfw3.h>
#include<optional>

struct s {
    std::optional<uint32_t> num;//Intellisense Error
};

int main() {
    return 5;
}

我从一个空项目开始,添加了包含和库;我可以在不包括 std::optional 的情况下编译和运行。

当我使用 std::optional 时,我得到 c2039“可选不是 std 的成员”

我正在运行 Windows 10 和 VisualStudio 2019

这里发生了什么 ?

谢谢。

4

1 回答 1

12

std::optional需要 C++17。

住在神螺栓上。

您可以在 on和on 上使用/std:c++17标志。MSVC-std=c++17gcc/clang

于 2020-06-14T08:34:54.703 回答