我正在做 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;
}
Run Code Online (Sandbox Code Playgroud)
我从一个空项目开始,并添加了包含和库;我可以在不包含 std::optional 的情况下编译和运行。
当我使用 std::optional 时,我得到 c2039 "optional is not a member of std"
我正在运行 Windows 10 和 VisualStudio 2019
这里发生了什么 ?
谢谢。
std::optional需要 C++17。
住在Godbolt 上。
你可以/std:c++17在MSVC和-std=c++17上使用标志gcc/clang。