编辑
我接受过关于这个话题的教育,我决定结束这个问题,
在评论中,有人能告诉我如何结束我的问题吗?
这里有一些我想编译的简单的C++代码。我目前在一台mac电脑上运行着MacOS Big,我没有<bits/stdc++.h>
文件作为所有cpp
文件的“默认”头。为了添加它,我进入了我的/Library/Developer/CommandLineTools/usr/include/c++/v1
文件夹,手动创建了一个带有stdc++.h
文件的bits
文件夹。但是,如果我试图编译包含此标头的源代码,则会出现以下错误:
test.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
这里也是我的clang版本:
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
我想要实现的
bits/stdc++.h
文件成功编译代码。(最好使用clang++
.我已经尝试过的
我的源代码
#include <bits/stdc++.h>
int main()
{
cout << "Meow Meow Meow\n";
return 0;
}
发布于 2022-07-22 11:51:09
首先- it's greatly discouraged to use headers like stdc++.h
.
如果您想这样做,您需要找到您的clang
版本所查看的系统目录。在终端中运行以下命令:
% touch file.cpp
% clang++ -c file.cpp -v
在底部,它应该给出如下的输出:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include
...
只需选择一个您认为更适合您的自定义标题目录,然后添加您想要包含的任何内容:
% cd /usr/local/include
% sudo mkdir bits && cd bits
% sudo touch stdc++.h
现在,表单#include <bits/stdc++.h>
的include指令应该可以使用任何用clang编译的cpp文件。您只需要用内容填充它。
https://stackoverflow.com/questions/73079603
复制相似问题