Re: Windows build warnings

From: Greg Nancarrow <gregn4422(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Windows build warnings
Date: 2021-11-24 00:36:30
Message-ID: CAJcOf-eoRXO-zpN0N50paP4k79qOuVBf3eMJMK_x1pw78kr+4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 24, 2021 at 1:41 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 2021-Nov-23, Juan José Santamaría Flecha wrote:
>
> > On Tue, Nov 23, 2021 at 2:11 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
> > > It's supported in clang as well per the documentation [0] in at least some
> > > configurations or distributions:
>
> > [[maybe_unused]] is also recognized from Visual Studio 2017 onwards [1].
> >
> > [1] https://docs.microsoft.com/en-us/cpp/cpp/attributes?view=msvc-170
>
> Right ... the problem, as I understand, is that the syntax for
> [[maybe_unused]] is different from what we can do with the current
> pg_attribute_unused -- [[maybe_unused]] goes before the variable name.
> We would need to define pg_attribute_unused macro (maybe have it take
> the variable name and initializator value as arguments?), and also
> define PG_USED_FOR_ASSERTS_ONLY in the same style.
>

Isn't "[[maybe_unused]]" only supported for MS C++ (not C)?
I'm using Visual Studio 17, and I get nothing but a syntax error if
trying to use it in C code, whereas it works if I rename the same
source file to have a ".cpp" extension (but even then I need to use
the "/std:c++17" compiler flag)

Regards,
Greg Nancarrow
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bossart, Nathan 2021-11-24 00:51:15 Re: XMAX_LOCK_ONLY and XMAX_COMMITTED (fk/multixact code)
Previous Message Mark Dilger 2021-11-24 00:35:56 Re: XMAX_LOCK_ONLY and XMAX_COMMITTED (fk/multixact code)