Re: Small patch: fix warnings during compilation on FreeBSD - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Small patch: fix warnings during compilation on FreeBSD
Date
Msg-id 1108.1457623250@sss.pgh.pa.us
Whole thread Raw
In response to Small patch: fix warnings during compilation on FreeBSD  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
Responses Re: Small patch: fix warnings during compilation on FreeBSD
List pgsql-hackers
Aleksander Alekseev <a.alekseev@postgrespro.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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Patch to implement pg_current_logfile() function
Next
From: Petr Jelinek
Date:
Subject: Re: Reworks of CustomScan serialization/deserialization