From owner-freebsd-ports@FreeBSD.ORG Mon Jun 2 20:00:16 2014 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06319B08 for ; Mon, 2 Jun 2014 20:00:16 +0000 (UTC) Received: from tensor.andric.com (unknown [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "tensor.andric.com", Issuer "CAcert Class 3 Root" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DE962E8C for ; Mon, 2 Jun 2014 20:00:15 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::c8e0:4fba:6528:ff7c] (unknown [IPv6:2001:7b8:3a7:0:c8e0:4fba:6528:ff7c]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 238025C43; Mon, 2 Jun 2014 22:00:08 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_654A7955-7120-4F9F-B349-9EC73219C5E4"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) Subject: Re: g++ cannot find std::stoi From: Dimitry Andric In-Reply-To: <87fvjnifpv.fsf@gmail.com> Date: Mon, 2 Jun 2014 21:59:56 +0200 Message-Id: <3404EC6D-277F-4607-AD5B-33B60C4F5C1E@FreeBSD.org> References: <874n09tr87.fsf@gmail.com> <44k3942y0w.fsf@be-well.ilk.org> <87fvjnifpv.fsf@gmail.com> To: hhh@sdf.org X-Mailer: Apple Mail (2.1878.2) Cc: Lowell Gilbert , freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jun 2014 20:00:16 -0000 --Apple-Mail=_654A7955-7120-4F9F-B349-9EC73219C5E4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 02 Jun 2014, at 15:49, hhh@sdf.org wrote: > Lowell Gilbert writes: >=20 >> hhh@sdf.org writes: >>=20 >>> I'm trying to compile OpenCog [1] using g++47, but get an error = about >>> missing std::stoi. >>>=20 >>> I have attached a micro-example [2] that generates the same error, = if I >>> try to compile it with: >>>=20 >>> % g++47 -std=3Dc++11 s.cc >>> s.cc: In function 'int main()': >>> s.cc:8:13: error: 'stoi' is not a member of 'std' >>>=20 >>>=20 >>> There are no problems neither with clang nor with g++ on Debian: >>>=20 >>> % clang++ -std=3Dc++11 s.cc >>>=20 >>>=20 >>>=20 >>> What am I missing? >>=20 >> An old libc++ bug in gcc. >>=20 >> You need a newer compiler. >=20 > I tried with gcc49 and it seem to have the same problem. This is because gcc's basic_string.h (from gcc 4.8 and higher) has the following conditional for declaring std::stoi() and friends: #if ((__cplusplus >=3D 201103L) && defined(_GLIBCXX_USE_C99) \ && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) Unfortunately libstdc++'s configure script thinks FreeBSD does not have proper C99 support, so it undefines _GLIBCXX_USE_C99, see = /usr/local/lib/gcc48/include/c++/i386-portbld-freebsd11.0/bits/c++config.h= around line 1238: /* Define if C99 functions or macros from , , = , , and can be used or exposed. */ /* #undef _GLIBCXX_USE_C99 */ This is also the case for the copy of c++config.h in the base system. The libstdc++ configure script says the following (excerpted): ... configure:16721: checking for ISO C99 support in configure:16852: g++48 -o conftest -std=3Dc++98 -fno-exceptions = conftest.cpp -lm >&5 conftest.cpp: In function 'int main()': conftest.cpp:52:19: error: 'clogf' was not declared in this scope tmpf =3D clogf(tmpf); ^ conftest.cpp:58:25: error: 'cpowf' was not declared in this scope tmpf =3D cpowf(tmpf, tmpf); ^ conftest.cpp:65:18: error: 'clog' was not declared in this scope tmpd =3D clog(tmpd); ^ conftest.cpp:71:24: error: 'cpow' was not declared in this scope tmpd =3D cpow(tmpd, tmpd); ^ conftest.cpp:75:21: error: 'ccosl' was not declared in this scope tmpld =3D ccosl(tmpld); ^ conftest.cpp:76:22: error: 'ccoshl' was not declared in this scope tmpld =3D ccoshl(tmpld); ^ conftest.cpp:77:21: error: 'cexpl' was not declared in this scope tmpld =3D cexpl(tmpld); ^ conftest.cpp:78:21: error: 'clogl' was not declared in this scope tmpld =3D clogl(tmpld); ^ conftest.cpp:79:21: error: 'csinl' was not declared in this scope tmpld =3D csinl(tmpld); ^ conftest.cpp:80:22: error: 'csinhl' was not declared in this scope tmpld =3D csinhl(tmpld); ^ conftest.cpp:82:21: error: 'ctanl' was not declared in this scope tmpld =3D ctanl(tmpld); ^ conftest.cpp:83:22: error: 'ctanhl' was not declared in this scope tmpld =3D ctanhl(tmpld); ^ conftest.cpp:84:28: error: 'cpowl' was not declared in this scope tmpld =3D cpowl(tmpld, tmpld); ^ ... configure:16861: result: no configure:16870: checking for ISO C99 support in configure:16927: g++48 -o conftest -std=3Dc++98 -fno-exceptions = conftest.cpp -lm >&5 conftest.cpp: In function 'int main()': conftest.cpp:47:23: warning: deprecated conversion from string constant = to 'char*' [-Wwrite-strings] snprintf("12", 0, "%i"); ^ configure:16927: $? =3D 0 configure:16938: result: yes configure:16942: checking for ISO C99 support in configure:17011: g++48 -o conftest -std=3Dc++98 -fno-exceptions = conftest.cpp -lm >&5 conftest.cpp:38:7: error: 'lldiv_t' does not name a type lldiv_t mydivt; ^ conftest.cpp: In function 'int main()': conftest.cpp:45:35: error: 'strtoll' was not declared in this scope ll =3D strtoll("gnu", &tmp, 10); ^ conftest.cpp:46:36: error: 'strtoull' was not declared in this scope ll =3D strtoull("gnu", &tmp, 10); ^ conftest.cpp:47:20: error: 'llabs' was not declared in this scope ll =3D llabs(10); ^ conftest.cpp:48:7: error: 'mydivt' was not declared in this scope mydivt =3D lldiv(10,1); ^ conftest.cpp:48:26: error: 'lldiv' was not declared in this scope mydivt =3D lldiv(10,1); ^ conftest.cpp:51:22: error: 'atoll' was not declared in this scope ll =3D atoll("10"); ^ ... configure:17022: result: no configure:17029: checking for ISO C99 support in configure:17049: g++48 -c -std=3Dc++98 -fno-exceptions conftest.cpp = >&5 conftest.cpp:38:17: error: '::wcstoll' has not been declared using ::wcstoll; ^ conftest.cpp:39:17: error: '::wcstoull' has not been declared using ::wcstoull; ^ ... configure:17182: checking for fully enabled ISO C99 support configure:17184: result: no The end result is that quite a lot of functionality in libstdc++'s headers is being disabled because of this. My advice is to use libc++ for now, which has no such problems, and can also be used with gcc 4.8 or higher. -Dimitry --Apple-Mail=_654A7955-7120-4F9F-B349-9EC73219C5E4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iEYEARECAAYFAlOM18MACgkQsF6jCi4glqM1jACfU65bdxF/hO+QqnQ3BbNbqDsK 9QwAn1vJ37eUboxzht1EVPrjV7xBhN4b =dE1z -----END PGP SIGNATURE----- --Apple-Mail=_654A7955-7120-4F9F-B349-9EC73219C5E4--