Re: simplehash.h: "SH_SCOPE static" causes warnings - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: simplehash.h: "SH_SCOPE static" causes warnings
Date
Msg-id 42a0fef1e345a9c9aaf800a71d0aad6c7630e166.camel@j-davis.com
Whole thread Raw
In response to Re: simplehash.h: "SH_SCOPE static" causes warnings  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: simplehash.h: "SH_SCOPE static" causes warnings
List pgsql-hackers
On Tue, 2024-04-09 at 14:49 -0400, Robert Haas wrote:
> Hmm. I'm pretty sure that I've run into this problem, but I concluded
> that I should use either "static inline" or "extern" and didn't think
> any more of it.

Pages of warnings is not ideal, though. We should either support
"SH_SCOPE static", or have some kind of useful #error that makes it
clear that we don't support it (and/or don't think it's a good idea).

>  I'm not sure that I like the idea of just ignoring the
> warnings, for fear that the compiler might not actually remove the
> code for the unused functions from the resulting binary. But I'm not
> an expert in this area either, so maybe I'm wrong.

In a simple "hello world" test with an unreferenced static function, it
doesn't seem to be a problem at -O2. I suppose it could be with some
compiler somewhere, or perhaps in a more complex scenario, but it would
seem strange to me.

Regards,
    Jeff Davis




pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: post-freeze damage control
Next
From: Jeff Davis
Date:
Subject: Re: simplehash.h: "SH_SCOPE static" causes warnings