Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“使用”的缺点是什么;“雨伞”;C项目中的标题?_C_Include - Fatal编程技术网

“使用”的缺点是什么;“雨伞”;C项目中的标题?

“使用”的缺点是什么;“雨伞”;C项目中的标题?,c,include,C,Include,我在一个C项目中看到了一个有趣的模式:他们在组件内部的任何地方都使用了伞形标题(包含组件中的所有内容的标题) h: #include "component_file1.h" #include "component_file2.h" /* #include each and every header of the component */ 组件_文件1.h: #include "umbrella.h" /*include guard and header*/ 组件文件1.c: #includ

我在一个C项目中看到了一个有趣的模式:他们在组件内部的任何地方都使用了伞形标题(包含组件中的所有内容的标题)

h:

#include "component_file1.h"
#include "component_file2.h"
/* #include each and every header of the component */ 
组件_文件1.h:

#include "umbrella.h"
/*include guard and header*/
组件文件1.c:

#include "umbrella.h"
/*c code*/
其他文件中的模式相同。我得到的解释是:

  • 在那个项目中,编译时间并不重要
  • 它易于使用(不需要知道标题层次结构)
  • 另一个技术细节:在umbrane.h中,他们对include指令进行了排序,以解决内部依赖关系(例如,如果component_file_2.h使用component_file_1.h,则顺序为:component_file_1.h,然后是component_file_2.h)

    除了编译时间外,这种方法是否存在任何严重的缺点,从而会影响它的使用?使用这种方法的代码重构有哪些标准是合理的?

    评论已经发表。在编辑澄清这不仅仅是征求意见之后,我才重新开始这篇文章。许多编程问题自然会涉及到意见,特别是关于结构和设计的意见。关键是我们需要基于事实和专业知识的支持意见。对于堆栈溢出,我看不出有什么理由不讨论这个问题。答案可以根据客观标准来判断。