[Development] Using '#pragma once' instead of include guards?

Kyle Edwards kyle.edwards at kitware.com
Fri Oct 14 15:47:49 CEST 2022


On 10/14/22 03:15, Eike Ziller wrote:
>> However, there are ways to enforce the use of unique header guards. clang-tidy has an extensible header guard check that can be customized per-project, and plugin loading functionality. Qt could create a clang-tidy plugin that sets up this header guard check and enforces a unique-enough header guard in CI.
> That works to avoid clashes inside a project, but doesn't help if user applications mix Qt + their code + other libraries not under their control, which is similar to the issues of #pragma once.

My point was that a naming scheme could be enforced that would make it 
very unlikely for an external project's header guards to conflict with 
the ones from Qt. I will leave it as an exercise to the reader to come 
up with such a scheme.

Kyle



More information about the Development mailing list