Replace header guards style with #pragma once#102298
Conversation
|
Should probably be handled safely generally but just to confirm one area of potential issue: |
|
Heh, I remember the time when @vnen said it is wrong idea: #18143 (comment) |
Verified locally that it does work!
I understand the hesitation for adding non-standard functionality, but I can make an exception here for a few reasons:
|
#pragma once#pragma once
Yeah it's fine I've been using I'm personally in favour of As we said last time:
|
cb27716 to
7c9cac4
Compare
|
If explicit affirmation is necessary, then I'll echo that I'm very much in favor of this as well. In addition to the points lawnjelly already mentioned, it'll be MUCH less of a headache to enforce in terms of hooks/tools. The existing methods we have now are pretty hacky, because they have to account for the exact situations |
|
Just a thought, does this observably affect compile time? |
I tested this about half a month ago using |
Calinou
left a comment
There was a problem hiding this comment.
Makes sense to me. Changes to tests/create_test.py look good.
7c9cac4 to
a944877
Compare
fire
left a comment
There was a problem hiding this comment.
Looks good to me. Letting the core contributors have the final say.
While in theory |
|
It is done. |
|
Awesome to see this! I originally opened #90979 with |
An upcoming core meeting will touch on using
#pragma onceinstead of traditional header guards. This draft is meant to accompany that future discussion, as it showcases the overall scope of a total conversion. While this would affect virtually every non-thirdparty header in the repo, the scope is isolated to such an extent that it can be safely excluded via.git-blame-ignore-revs. Changes to non-header files — builders, pre-commit, etc — were handled in a separate commit which would not be excluded. Does not convert headers for*-so_wrap.hfiles (generated externally),nor ObjC files (guards shouldn't be there in the first place, but removing them is out-of-scope; handled in #101174 instead).EDIT: Now also includes ObjC files, as their compilers also handle
#pragma oncejust fine. Having them included means that the logic for checking header guards has been reduced significantly.