Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

VSCode 误报语法错误

我在 mac osx 上用 vscode 写 c++,用的微软官方的 c++扩展,运行参数用的是g++ -std=c++2a。XCode 自带clang,输入g++会自动连接使用clang,我另外下了个gcc/g++,在zshrc中写入alias gcc='gcc-10' alias g++='g++-10',现在输入g++ --version显示的是g++-10 (Homebrew GCC 10.2.0) 10.2.0。我现在写一些 c++17 及以后的语法,比如std::vector arr; 或者std::vector arr{1, 2, 3};程序编译运行没问题,但会有红色波浪线提示错误( argument list for class template "std::vector" is missing ),而且该段代码编辑器没有语法高亮。换成std::vector<int> arr;或者std::vector<int> arr{1, 2, 3};之后错误警告就消失了,代码的语法高亮也正确了。类似,输入std::size()会出现提示namespace "std" has no member "size",但是可以成功运行得到某个数组的长度。

这是哪里设置出问题了,需要哪里再另外设置吗?现在的代码语法检测用的好像没有用到最新的std


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...