Re: make pg_attribute_noreturn() work for msvc?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: make pg_attribute_noreturn() work for msvc?
Date: 2019-11-12 22:11:40
Message-ID: 20191112221140.fg44zmerbfbyg6dq@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-11-12 15:58:07 -0500, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > So perhaps we ought to rename pg_attribute_noreturn() to pg_noreturn(),
> > add a __declspec(noreturn) version, and move the existing uses to it.
>
> > I'm inclined to also drop the parentheses at the same time (i.e
> > pg_noreturn rather than pg_noreturn()) - it seems easier to mentally
> > parse the code that way.
>
> I guess my big question about that is whether pgindent will make a
> hash of it.

If one writes 'pg_noreturn void', rather than 'void pg_noreturn', then
there's only one place where pgindent changes something in a somewhat
weird way. For tablesync.c, it indents the pg_noreturn for
finish_sync_worker(). But only due to being on a separate newline, which
seems unnecessary…

With 'void pg_noreturn', a few prototypes in headers get indented more
than pretty, e.g. in pg_upgrade.h it turns

void pg_noreturn pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2);
into
void pg_noreturn pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2);

I'm a bit confused as to why pg_upgrade.h doesn't use 'extern' for
function declarations? Not that it's really related, except for the
'extern' otherwise hiding the effect of pgindent not liking 'void
pg_noreturn'…

I don't see a reason not to go for 'pg_noreturn void'?

> One idea is to merge it with the "void" result type that such
> a function would presumably have, along the lines of
>
> #define pg_noreturn void __declspec(noreturn)
> ...
> extern pg_noreturn proc_exit(int);

> and if necessary, we could strongarm pgindent into believing
> that pg_noreturn is a typedef.

Yea, that'd be an alternative. But since not necessary, I'd not go
there?

Greetings,

Andres Freund

Attachment Content-Type Size
v1-0001-Change-pg_attribute_noreturn-to-pg_noreturn-move-.patch text/x-diff 34.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan S. Katz 2019-11-12 22:17:37 2019-11-14 Press Release Draft
Previous Message Alvaro Herrera 2019-11-12 21:55:46 Re: [PATCH] Do not use StdRdOptions in Access Methods