[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Headers without multiple inclusion guards
From: |
Laszlo Ersek |
Subject: |
Re: [Qemu-devel] Headers without multiple inclusion guards |
Date: |
Wed, 5 Jun 2019 19:03:31 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 06/05/19 18:23, Daniel P. Berrangé wrote:
> On Wed, Jun 05, 2019 at 06:18:38PM +0200, Laszlo Ersek wrote:
>> On 06/05/19 16:23, Daniel P. Berrangé wrote:
>>> On Tue, May 28, 2019 at 08:12:24PM +0200, Markus Armbruster wrote:
>>>> We have a bunch of headers without multiple inclusion guards. Some are
>>>> clearly intentional, some look accidental. Too many for me to find out
>>>> by examining each of them, so I'm asking their maintainers.
>>>>
>>>> Why do I ask? I'd like to mark the intentional ones and fix the
>>>> accidental ones, so they don't flunk "make check-headers" from "[RFC v4
>>>> 0/7] Baby steps towards saner headers" just because they lack multiple
>>>> inclusion guards.
>>>>
>>>> Just in case: what's a multiple inclusion guard? It's
>>>>
>>>> #ifndef UNIQUE_GUARD_SYMBOL_H
>>>> #define UNIQUE_GUARD_SYMBOL_H
>>>> ...
>>>> #endif
>>>>
>>>> with nothing but comments outside the conditional, so that the header
>>>> can safely be included more than once.
>>>
>>> Any opinions on using the less verbose syntax instead:
>>>
>>> #pragma once
>>>
>>> It is not portable C, but we explicitly only care about GCC or CLang,
>>> so portability isn't an issue for us.
>>
>> I don't feel strongly about this particular question, so if folks prefer
>> "#pragma once", I won't complain. I'd just like to report that section 6
>> of "HACKING" appears the opposite of "we explicitly only care about GCC
>> or CLang".
>
> Heh, yeah that doc does require some updating, as we certainly don't
> require conformance to the vanilla C standard any more. We now explicitly
> request "-std=gnu99" as the conformance level which allows many GNU
> extensions to the standard.
>
> commit 7be41675f7cb16be7c8d2554add7a63fa43781a8
> Author: Thomas Huth <address@hidden>
> Date: Mon Jan 7 11:25:22 2019 +0100
>
> configure: Force the C standard to gnu99
>
> Different versions of GCC and Clang use different versions of the C
> standard.
> This repeatedly caused problems already, e.g. with duplicated typedefs:
>
> https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html
>
> or with for-loop variable initializers:
>
> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html
>
> To avoid these problems, we should enforce the C language version to the
> same level for all compilers. Since our minimum compiler versions is
> GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not
> available there yet, and "gnu11" is marked as "experimental"), and
> "gnu++98"
> for the few C++ code that we have in the repository.
TIL :)
Thanks!
Laszlo
> The HACKING docs predate this commit, and when reviewing, we failed to
> notice we needed to update HACKING to match our new policy.
>
> Regards,
> Daniel
>
Re: [Qemu-devel] Headers without multiple inclusion guards, Alistair Francis, 2019/06/05