This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 06/25] Add struct scratch_buffer and its internal helper functions
- From: Florian Weimer <fweimer at redhat dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: Andreas Schwab <schwab at suse dot de>, libc-alpha at sourceware dot org
- Date: Mon, 02 Mar 2015 18:54:49 +0100
- Subject: Re: [PATCH 06/25] Add struct scratch_buffer and its internal helper functions
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1425285061 dot git dot fweimer at redhat dot com> <7a6fe503fb764beee3d5b89662d3bbf65242161c dot 1425285061 dot git dot fweimer at redhat dot com> <mvm7fuzwxmg dot fsf at hawking dot suse dot de> <54F4301E dot 7090704 at redhat dot com> <20150302174229 dot GY23507 at brightrain dot aerifal dot cx>
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