RFR (tedious) 8216022: Use #pragma once
Thomas Stüfe
thomas.stuefe at gmail.com
Fri Jan 4 17:24:28 UTC 2019
On Fri, Jan 4, 2019 at 4:01 PM David Lloyd <david.lloyd at redhat.com> wrote:
> In the end though this is an example of the kind of change that I for
> one would never allow in one of my projects: it's large, potentially
> impacts portability, and yet in the end it's not really necessary,
> being really just a style issue when it comes right down to it.
> Include guards are standard and portable. '#pragma once' is not.
>
> --
> - DML
FWIW, I agree with David on this. Include guards are a simple
mechanism, while the potential troubles surrounding #pragma once worry
me. Include guard errors are easy to find and fix. But the potential
issues with pragma once sound difficult to analyze and almost
impossible to fix if the compiler turns out to be the culprit.
Note that at SAP people tend to build out-of-tree and often across
file system borders, with sources on a shared file system and a local
output directory. So yes, that is a common usage scenario.
That said, I can understand Erik's pain when creating/changing so many
includes. But how common is this scenario? Changing so many include
files happens usually in the course of major rewrites which I would
hope do not occur so often that we need to optimize our workflow for
them. After all, these changes also bring other disruption: file
history gets broken, it is more difficult to compare code across JDK
versions etc.
Bottomline I would prefer keeping include guards and maybe add a tool
to generate include guards automatically.
Thanks, Thomas
More information about the hotspot-dev
mailing list