Are redundant include guards necessary?

前端 未结 3 1021
野的像风
野的像风 2020-12-19 15:42

Are \'redundant include guards\' necessary in Codegear RAD Studio 2009? Is the compiler smart enough to deal with this on it\'s own?

For example, I might have the fo

3条回答
  •  情歌与酒
    2020-12-19 15:51

    These redundant include guards are intended to emulate the functionality of the proposed #pragma once directive: if some header file has already been included, then the preprocessor will not even attempt to locate, open and parse it anymore (as it would have to with the "ordinary" include guard technique). In many cases this makes handling of include files much more efficient (speeds up compilation).

    This approach is obviously a high-maintenance one: one has to make sure that the spelling of the guard symbol is exactly the same inside the header file as well as outside.

提交回复
热议问题