Double-include guard

Bug #1398211 reported by Michi Henning
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
canonical-development-guidelines
New
Undecided
Unassigned

Bug Description

We recently change our double-include guards to use

#pragma once

That's a lot briefer than the usual #ifndef ... #define ... #endif guard. It also is safer: I've more than once made the mistake of copying a header file to create new similar header and forgetting to update the guard symbol. When things don't compile, it can be quite difficult to find which header blocks inclusion of some other header because they both use the same guard symbol...

The pragma works for gcc, clang (and even Visual C++), which are pretty much the only compilers that matter these days, except maybe for Visual C++ ;-)

I think we should update the guide accordingly.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.