RFR (tedious) 8216022: Use #pragma once
Andrew Haley
aph at redhat.com
Sat Jan 5 11:31:27 UTC 2019
On 1/4/19 3:59 PM, Erik Österlund wrote:
> On 2019-01-04 15:59, David Lloyd wrote:
>> In addition, it was pointed out to me that if, for some reason, a
>> header file ends up in more than one location on the include path,
>> #pragma once will (probably, as it's not standardized) allow it to
>> be included twice, which #ifdef guards avoid. This is perhaps not
>> a real concern in this particular code base though.
>
> That sounds like a bug. Just because something is implementation
> defined, doesn't make it okay or expected to not work. Do you know
> how to reproduce this, and on which platform/compiler/version?
> Obviously, if this was an issue in our code base, one would quickly
> notice it doesn't build.
It's not a bug, exactly. It's that the question of "is this the same
file?" is extremely difficult to answer definitively. Not all
filesystems give you a reliable way to answer that question. Sure, you
can kludge around the problem with modification times and maybe even a
collision-free hash, but getting it really correct is not going to be
efficient, and not even possible until that question is rigorously
defined. There's a good reason why #pragma once still isn't standard.
--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-dev
mailing list