简体   繁体   English

我的代码中包含第三方.h 文件

[英]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.

相关问题 使用包含“ .h”,“。lib”和“ .dll”文件的第三方库 - Using a Third Party Library Consisting of “.h”, “.lib” and “.dll” Files 麻烦包括我的C ++应用程序中的第三方代码 - Trouble including third-party code in my C++ application 如果我可以在.h文件中包含所有C ++代码,为什么要使用.cpp文件? - Why to use .cpp files if I can have all of my C++ code in .h file? 包含在项目中的第三方库抛出编译错误 - Third party library throwing compilation errors when being included in project 当第三方代码中没有警告时,为什么不将所有警告视为错误? - Why exactly not treat all warnings as errors when there're no warnings in third party code? 只能使用(稳定)第三方库使我的代码无法正常工作 - Can merely using (stable) third party library render my code not working Static 将第三方库与我的 C++ 包装代码链接在一起 - Static linking third party libraries together with my C++ wrapper code 如何从第三方框架和源代码创建框架? - How can i create a framework from a third party framework and my source code? 从第三方代码检查库版本 - Check library version from third party code 带有反调试代码的第三方库 - third party library with anti-debug code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM