Wrapping #includes in #ifndef's - adds any value?

前端 未结 2 1109
陌清茗
陌清茗 2021-01-19 19:19

I have inherited C/C++ code base, and in a number of .cpp files the #include directives are wrapped in #ifndef\'s with the headers internal sin

2条回答
  •  渐次进展
    2021-01-19 19:25

    If a file is included, then that whole file has to be read, and even the overhead of opening/closing the file might be significant. By putting the guarding directives around the include statement, it never has to be opened. As always with these questions, the correct answer is: try taking out the ifndef/endif guards around the include directives and get your stopwatch...

提交回复
热议问题