Problem with gcc5 std library when building ports

Dimitry Andric dim at
Sun Oct 30 02:31:51 UTC 2016

On 27 Oct 2016, at 01:01, Dewayne Geraghty <dewaynegeraghty at> wrote:
> Can anyone help regarding the apparant absence of snprintf from std?  Am I
> missing something, perhaps LDCONFIG or?  I've looked in /usr/ports/Mk/
> and /usr/ports/Mk/ but this is an area that I'm
> unfamiliar, so nothing really stood out.
> If I change the compiler from gcc5 to clang everything compiles and runs
> correctly. I have in /etc/make.conf
> USE_GCC=  5
> and to use clang, I just comment out the above. So everything is constant,
> on FreeBSD 10.3Stable (updated and rebuilt overnight)

The difference is that clang by default uses libc++, while gcc uses
libstcd++.  Unfortunately, our gcc ports have a long-standing problem
with recognition of C99 functionality for their copies of libstdc++.

If you look in gcc5's <cstdio> header, usually located in
/usr/local/lib/gcc5/include/c++/cstdio, you will see this:


#undef snprintf

namespace __gnu_cxx
  extern "C" int
  (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...)
  throw ();

  using ::snprintf;
} // namespace __gnu_cxx

namespace std
  using ::__gnu_cxx::snprintf;
} // namespace std

#endif // _GLIBCXX_USE_C99

So in a slightly convoluted way, it only defines std::snprintf() when
_GLIBCXX_USE_C99 is defined.

However, during the port build, the gcc configuration mechanism seems to
conclude that C99 support is *not* available, and stores this in

/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>,
   <stdio.h>, and <stdlib.h> can be used or exposed. */
/* #undef _GLIBCXX_USE_C99 */

This has been the case for ages now, and there must be lots of bug
reports for it, but it has not been fixed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <>

More information about the freebsd-ports mailing list