Re: Small patch: fix warnings during compilation on FreeBSD

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small patch: fix warnings during compilation on FreeBSD
Date: 2016-03-10 15:20:50
Message-ID: 1108.1457623250@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru> writes:
> I noticed that master branch of PostgreSQL currently compiles with
> warnings on FreeBSD 10.2 RELEASE:
> pg_locale.c:1290:12: warning: implicit declaration of function
> 'wcstombs_l' is invalid in C99 [-Wimplicit-function-declaration]

> The problem is that both procedures are declared in xlocale.h file
> which is not included in given context.

OK.

> Frankly I'm not sure what is a right way of fixing this.

Not like that, as it will break entirely on machines without xlocale.h
(which I presume is pretty nonstandard; it's certainly not mentioned
in the POSIX spec). It will also break things on glibc, according to
this comment in our c-library.m4:

# Check for the locale_t type and find the right header file. Mac OS
# X needs xlocale.h; standard is locale.h, but glibc also has an
# xlocale.h file that we should not use.

I think what we need is configure logic to find out where wcstombs_l()
is declared, and then #include <xlocale.h> only if it's necessary to get
that definition. I haven't experimented but probably you could make such
a check with nested uses of AC_CHECK_DECL.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2016-03-10 15:26:41 Re: Reworks of CustomScan serialization/deserialization
Previous Message Robert Haas 2016-03-10 15:20:31 Re: Patch to implement pg_current_logfile() function