Is #pragma once a safe include guard?

后端 未结 14 2523
青春惊慌失措
青春惊慌失措 2020-11-22 07:42

I\'ve read that there is some compiler optimization when using #pragma once which can result in faster compilation. I recognize that is non-standard, and thus

14条回答
  •  情深已故
    2020-11-22 07:53

    If we use msvc or Qt (up to Qt 4.5), since GCC(up to 3.4) , msvc both support #pragma once, I can see no reason for not using #pragma once.

    Source file name usually same equal class name, and we know, sometime we need refactor, to rename class name, then we had to change the #include XXXX also, so I think manual maintain the #include xxxxx is not a smart work. even with Visual Assist X extension, maintain the "xxxx" is not a necessary work.

提交回复
热议问题