[英]Third party .h files included all over my code
I gathered a bunch of definitions from multiple third party.h files.我从多个第三方.h 文件中收集了一堆定义。
// my_header.h
#include "thrd_party_header1.h"
#include "thrd_party_header2.h"
#define MY_DEFINE_1 THRD_PARTY_DEFINE_1
#define MY_DEFINE_2 THRD_PARTY_DEFINE_2
//etc...
Problem is that now each class file including my_header.h
"sees" all those 3rd party includes.问题是现在每个 class 文件,包括
my_header.h
“看到”所有这些第 3 方包括。 I don't want that.我不想要那个。 What can I do to minimize the headers used in my.cpp?
我可以做些什么来最小化 my.cpp 中使用的标头?
Would this work?这行得通吗?
//my_header.h
#ifdef SEE_DEFINES
#include "thrd_party_header1.h"
#include "thrd_party_header2.h"
#endif
Then you can include my_header.h without seeing the third party headers, and when you want to see them just do然后你可以在不看到第三方标题的情况下包含 my_header.h,当你想看到它们时就做
#define SEE_DEFINES
#include "my_header.h"
#undef SEE_DEFINES
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.