Why isn't C/C++'s “#pragma once” an ISO standard?

前端 未结 9 1693
说谎
说谎 2020-11-28 11:29

I am currently working on a big project and maintaining all those include guards makes me crazy! Writing it by hand is frustrating waste of time. Although many editors can g

9条回答
  •  我在风中等你
    2020-11-28 12:17

    1. How often do you have to add an include file to this project? Is it really so hard to add DIRNAME_FILENAME to the guard? And there is always GUIDs.
    2. Do you really rename files that often? Ever? Also, putting the GUARD in the #endif is just as annoying as any other useless comment.
    3. I doubt your 1000 header files guard defines are even a small percentage of the number of defines generated by your system libraries (especially on Windows).
    4. I think MSC 10 for DOS (20+ years ago) kept track of what headers were included and if they contained guards would skip them if included again. This is old tech.
    5. namespaces and templates should not span headers. Dear me, don't tell me you do this:

      template 
      class bar {
      #include "bar_impl.h"
      };
      
    6. You said that already.

提交回复
热议问题