Re: Patch: Remove gcc dependency in definition of inline functions

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Kurt Harriman <harriman(at)acm(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch: Remove gcc dependency in definition of inline functions
Date: 2010-01-19 16:01:27
Message-ID: 1263916887.27134.8.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On tis, 2010-01-19 at 01:29 -0800, Kurt Harriman wrote:
> On 1/18/2010 11:48 PM, Peter Eisentraut wrote:
> We have some existing inline functions in .c files. These can be
> more complicated, so it might be ok if the compiler decides to
> leave them out-of-line. And they are never unreferenced, so
> suppression of unused-function warnings is not necessary and
> perhaps not wanted. To leave these functions undisturbed, my patch
> doesn't redefine the "inline" keyword; instead it adds a new #define
> PG_INLINE for use in header files where unused-function warnings
> need to be suppressed.

One principle that I suppose should have been made more explicit is that
-- in my mind -- we should avoid littering our code with nonstandard
constructs in place of standard constructs. Because the next generation
of developers won't know what PG_INLINE is and why we're not using plain
inline, even if we document it somewhere.

That said, ...

> > Is there not a setting to disable this particular warning. I read that
> > MSVC has various ways to set that sort of thing.
>
> Yes, warnings can be turned off by a #pragma specifying the
> warning number.

> Or compiler switches could be set to disable all such warnings
> globally. Warning 4514 is specific to inline functions; so
> maybe it would be alright to keep it turned off globally.

... I think that would exactly be the right solution.

Then just replace in those two locations __GNUC__ by __GNUC__ ||
__MSVC__ (or whatever the symbol is). Or if you want to make it extra
nice, create a symbol somewhere like in c.h that reads

#define USE_INLINE __GNUC__ || __MSVC__

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-01-19 16:02:31 Re: Git out of sync vs. CVS
Previous Message Robert Haas 2010-01-19 15:59:39 Re: Git out of sync vs. CVS