This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 06/25] Add struct scratch_buffer and its internal helper functions


On 03/02/2015 06:42 PM, Rich Felker wrote:
> On Mon, Mar 02, 2015 at 10:40:46AM +0100, Florian Weimer wrote:
>> On 03/02/2015 10:35 AM, Andreas Schwab wrote:
>>> Florian Weimer <fweimer@redhat.com> writes:
>>>
>>>> +#pragma once
>>>
>>> Don't use pragma once.
>>
>> Why?  The GCC implementation was fixed ages ago, and it's not an
>> installed header file.
> 
> If for no other reason, cargo-culting. This is the wrong way to
> achieve multiple-include protection (it's non-portable and has a
> perfectly portable way to do the same thing)

It's portable to anything except Solaris Studio.  It's supported by the
EDG front end, so you have to do actual work to build a compiler that
doesn't support it.  (Not that it matters in this case because it is an
internal header anyway.)

Compare this to most C99 or even C11 features, which keep most of our
code in a world of its own (which is fine from my point of view,
pretend-portability without actual users doesn't work so well in practice).

And no, there is nothing else which provides a similar capability to
#pragma once, in a way that is equally portable in practice.

> and programmers will see and copy it into non-glibc code.

And that's a good thing because it avoids real bugs.

But of course I'll add a traditional #include guard.  Okay to commit
with such a change?

-- 
Florian Weimer / Red Hat Product Security


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]