编译器标志,用于将 some_file_name.h 包含在所有文件中
Compiler flag to include some_file_name.h into all files?
我正在写我的荣誉论文,想将我的线程方法从 std::threads 更改为包含 boost::threadpool。我只需做一个
#include "../include/threadpool.hpp"
在我的每个文件中,但是随着许多文件/对线程系统的更改,这变得非常重复。有没有办法提供编译器标志(或其他东西),以便所有文件本机 #include 该文件?
我天真的想法是这样的
//dependencies.h
#include "../include/threadpool.hpp"
#include //some other dependency I need.h
并通过一个
-我"path_to_dependencies.h"
标志到编译器。这样的事情会起作用还是我偏离了基础?
谢谢!
后者是首选方法。事实上,你可以更进一步,使其成为预编译的头文件,这将大大减少编译时间,特别是当你的项目变大的时候。
我假设您使用的是 gcc,您可以在此处阅读有关预编译标头的信息:https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html
对于Microsoft的编译器,您拥有每个人都知道的stdafx.h
文件,因为它默认启用预编译标头。
相关文章:
- vcruntime.h 从 Windows 包含文件夹中丢失?
- 禁止显示有关包含文件中 #pragma 包的警告
- 无法打开包含文件:在 vs2017 上'QtWidgets/qtwidgetsglobal.h'
- 包含文件 <sched_yield.h>在我的 RHEL 5 上找不到
- 尝试使用 MSVC 从源代码构建 qt 创建器:无法打开包含文件:"stddef.h":没有这样的文件或目录
- 无法打开包含文件'Graphics.hpp'没有这样的文件或目录,Visual Studio的其他包含不起作用
- 为什么 C++ 编译器在"c:program filesgnu emacsinclude"中查找包含文件?
- 包含文件中的 Typdef "未在此范围内声明"
- 错误: C1083: 无法打开包含文件:"boost/asio.hpp": 没有此类文件或目录
- SFML c ++ 当包含文件内游戏中发生事件时,如何使用铃声函数为我的游戏创建声音类?
- 在Windows上设置CMake和vcpkg时出错"无法打开包含文件"
- 致命错误 C1083:无法打开包含文件:"GL/glew.h":没有此类文件或目录
- Qt自动生成的.rc文件无法打开包含文件'windows.h'
- Visual Studio 停止识别任何包含文件
- 无法打开包含文件:"签证.h"
- 如何检查每个头文件是否包含必需的包含文件?
- Protobuf:无法在 message.pb.h 文件中打开包含文件 common.h
- extern 关键字在包含文件头文件C++
- 错误:无法打开包含文件:"MQTTAsync.h":没有此类文件或目录
- #include "date.h" 创建错误 E1696 无法打开源文件"date.h",也无法打开包含文件:没有这样的文件或目录