问题
使用 brew 更新了 gcc 之后, 编译一个 C++程序时候突然报了很多错. 这里仅截取一部分.
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/stdlib.h:351:9: error: expected initializer before '__API_AVAILABLE2'
351 | __API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0), watchos(6.0));
| ^~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/stdlib.h:359:9: error: expected initializer before '__API_AVAILABLE2'
359 | __API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0));
| ^~~~~~~~~~~~~~~
/opt/homebrew/Cellar/gcc/14.1.0/include/c++/14/cstdlib:173:11: error: 'system' has not been declared in '::'
173 | using ::system;
| ^~~~~~
解决
gcc 的版本为 14.1.0, 起初并不理解为什么, 网上也没有现成的解答.
后来思考了一下, 更新了 command line tools for xcode 之后就不报错了…