我正在尝试使用g ++编译器编译Cpp程序,但出现此错误:
Yuliam-MBP:Documents yuliamosh$ g++-9 -std=c++17 -Wall -Wextra -pedantic vector.cpp -o vector
In file included from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/bits/postypes.h:40,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iosfwd:40,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ios:38,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/ostream:3,
from /usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/iostream:39,
from vector.cpp:1:
/usr/local/Cellar/gcc/9.2.0_3/include/c++/9.2.0/cwchar:44:10: fatal error: wchar.h: No such file or directory
44 | #include <wchar.h>
| ^~~~~~~~~
compilation terminated.
安装xcode-select --install
切换到新安装的工具时sudo xcode-select --switch /Library/Developer/CommandLineTools/
您可能需要重置编译工具的默认位置:
xcode-select --reset
这些是通常的修复方法。 很遗憾,他们都不为我工作!
这对我有用:Homebrew Solution
似乎未找到“ wchar.h”。
我建议遵循this线程中的说明。