在 Mac OS Mojave 10.14.6 上使用 VS Code 处理一个奇怪的包含问题。
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/ajm/Projects/restaurant/cpp/sim/src/main.cpp).C/C++(1696)
cannot open source file "wchar.h" (dependency of "iostream")
Run Code Online (Sandbox Code Playgroud)
请注意,这种情况是在我将 MacOS CommandLineTools 更新为xcode-select --install.
我的编译器路径在 VS Code 中是
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
Run Code Online (Sandbox Code Playgroud)
我的 includePath 是
${workspaceFolder}/**
${BOOST_ROOT}/**
Run Code Online (Sandbox Code Playgroud)
当我添加/Library/Developer/CommandLineTools/usr/include/c++/v1/**到我的 includePath 并将编译器路径更改为 时/usr/bin/g++,STL 包含问题消失了,我得到了这个:
cannot open source file "boost/lambda/lambda.hpp"
Run Code Online (Sandbox Code Playgroud)
请注意,当我从命令行构建程序时,它运行得很好;一切都按其应有的样子被发现。
这是我的 Makefile:
PROG = sim
CC = g++
CPPFLAGS = -g -Wall -I$(SDIR) -I$(ODIR) -I$(BOOST_ROOT)
ODIR …Run Code Online (Sandbox Code Playgroud)