error: reference to ‘uint64_t’ is ambiguous

665 views
Skip to first unread message

Volker Braun

unread,
Aug 11, 2015, 3:02:05 PM8/11/15
to cython-users
On some platforms (probably depending on the gcc version) I get the following error in boost-using Cython code. Presumably this is triggered by the new small integer optimizations, as Cython-0.22 did not include longintrepr.h.  In C++ one should disambiguate ::uint64_t, but then longintrepr.h is a C Python header. Arguably it is the fault of the code for

using namespace std;
using namespace boost;

in the user code but then its a common enough (ab)use. Thoughts?


gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/mnt/disk/home/release/Sage/local/include -I/mnt/disk/home/release/Sage/local/include/python2.7 -I/mnt/disk/home/release/Sage/local/lib/python2.7/site-packages/numpy/core/include -I/mnt/disk/home/release/Sage/src -I/mnt/disk/home/release/Sage/src/sage/ext -I/mnt/disk/home/release/Sage/src/build/cythonized -I/mnt/disk/home/release/Sage/src/build/cythonized/sage/ext -I/mnt/disk/home/release/Sage/local/include/python2.7 -c /mnt/disk/home/release/Sage/src/build/cythonized/sage/graphs/base/boost_graph.cpp -o build/temp.linux-x86_64-2.7/mnt/disk/home/release/Sage/src/build/cythonized/sage/graphs/base/boost_graph.o -fno-strict-aliasing -w
In file included from build/cythonized/sage/graphs/base/boost_graph.cpp:8205:0:
../local/include/python2.7/longintrepr.h:47:9: error: reference to ‘uint64_t’ is ambiguous
 typedef PY_UINT64_T twodigits;
         ^
In file included from /usr/lib/gcc/x86_64-redhat-linux/5.1.1/include/stdint.h:9:0,
                 from /usr/include/inttypes.h:27,
                 from ../local/include/python2.7/pyport.h:9,
                 from ../local/include/python2.7/Python.h:58,
                 from build/cythonized/sage/graphs/base/boost_graph.cpp:38:
/usr/include/stdint.h:55:27: note: candidates are: typedef long unsigned int uint64_t
 typedef unsigned long int uint64_t;
                           ^
In file included from ../local/include/boost/integer_fwd.hpp:17:0,
                 from ../local/include/boost/integer/static_log2.hpp:19,
                 from ../local/include/boost/functional/hash/detail/hash_float.hpp:17,
                 from ../local/include/boost/functional/hash/hash.hpp:15,
                 from ../local/include/boost/functional/hash.hpp:6,
                 from ../local/include/boost/unordered/unordered_set.hpp:20,
                 from ../local/include/boost/unordered_set.hpp:16,
                 from ../local/include/boost/graph/adjacency_list.hpp:21,
                 from build/cythonized/sage/graphs/base/boost_graph.cpp:287:
../local/include/boost/cstdint.hpp:311:39: note:                 typedef boost::ulong_long_type boost::uint64_t
      typedef  ::boost::ulong_long_type   uint64_t;
                                       ^
In file included from build/cythonized/sage/graphs/base/boost_graph.cpp:8205:0:
../local/include/python2.7/longintrepr.h:48:9: error: reference to ‘int64_t’ is ambiguous
 typedef PY_INT64_T stwodigits; /* signed variant of twodigits */
         ^
In file included from /usr/include/stdlib.h:314:0,
                 from ../local/include/python2.7/Python.h:42,
                 from build/cythonized/sage/graphs/base/boost_graph.cpp:38:
/usr/include/sys/types.h:197:13: note: candidates are: typedef long int int64_t
 __intN_t (64, __DI__);
             ^
In file included from ../local/include/boost/integer_fwd.hpp:17:0,
                 from ../local/include/boost/integer/static_log2.hpp:19,
                 from ../local/include/boost/functional/hash/detail/hash_float.hpp:17,
                 from ../local/include/boost/functional/hash/hash.hpp:15,
                 from ../local/include/boost/functional/hash.hpp:6,
                 from ../local/include/boost/unordered/unordered_set.hpp:20,
                 from ../local/include/boost/unordered_set.hpp:16,
                 from ../local/include/boost/graph/adjacency_list.hpp:21,
                 from build/cythonized/sage/graphs/base/boost_graph.cpp:287:
../local/include/boost/cstdint.hpp:308:38: note:                 typedef boost::long_long_type boost::int64_t
      typedef  ::boost::long_long_type            int64_t;
                                      ^

Robert Bradshaw

unread,
Aug 13, 2015, 1:43:12 AM8/13/15
to cython...@googlegroups.com
Could you manually set the PY_UINT64_T macro? 

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Volker Braun

unread,
Aug 13, 2015, 4:14:12 AM8/13/15
to cython-users
I haven't tried that. Obviously that would work (after also adding signed versions). But I wouldn't want to dig around in Python internals in the user code, thats going to be even more fragile. For Sage purposes I removed the global "using namespace"s, that fixes the problem and nicely illustrates why you shouldn't do it to begin with. 

Cython could presumably #include longintrepr.h at the beginning, before user code had any chance of screwing things up. 

Robert Bradshaw

unread,
Aug 14, 2015, 1:19:32 AM8/14/15
to cython...@googlegroups.com
On Thu, Aug 13, 2015 at 1:14 AM, Volker Braun <vbrau...@gmail.com> wrote:
> I haven't tried that. Obviously that would work (after also adding signed
> versions). But I wouldn't want to dig around in Python internals in the user
> code, thats going to be even more fragile. For Sage purposes I removed the
> global "using namespace"s, that fixes the problem and nicely illustrates why
> you shouldn't do it to begin with.
>
> Cython could presumably #include longintrepr.h at the beginning, before user
> code had any chance of screwing things up.

Good idea; done:
https://github.com/cython/cython/commit/25ec392a7ff723a5f87d76e8d69b1bf354fa95cf
(though I agree that these two using statements is shaky code...)
Reply all
Reply to author
Forward
0 new messages