Why isn't #pragma once automatically assumed?

后端 未结 6 995
盖世英雄少女心
盖世英雄少女心 2020-12-13 03:24

What\'s the point of telling the compiler specifically to include the file only once? Wouldn\'t it make sense by default? Is there even any reason to include a single file m

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 04:04

    No, this would significantly hinder the options available to, for example, library writers. For example, Boost.Preprocessor allows one to use pre-processor loops, and the only way to achieve those is by multiple inclusions of the same file.

    And Boost.Preprocessor is a building block for many very useful libraries.

提交回复
热议问题