Why not include all the standard headers always?

后端 未结 7 724
攒了一身酷
攒了一身酷 2021-01-03 19:02

I am reading Herb Sutter\'s More Exceptional C++ and item 37 on forward declarations says:

Never #include a

7条回答
  •  北海茫月
    2021-01-03 19:49

    Oh! I know a good one.

    I have one proprietary library for making nice zip archive files out of memory data. It was designed to be multiplatform, but apparently not tested well enough on every platform including Windows.

    It works great on Linux and other POSIX systems but as I tried to adopt it in my project, I've stubled upon this: How to suppress #define locally?

    Both the library and winbase.h (included via the most standart windows.h) has a CreateFile entity. And, as in winbase it's just a macros, compiler don't see any problem, unless you actually try to use CreateFile in your code.

    So yes, keeping your namespace clean might be a good idea.

提交回复
热议问题