I am trying to compile a specific library, that apparently compiles fine for the author, but not for me. The following code demonstrates the problem (at least for me):
Code:#include <iostream> using namespace std; class Test { public: inline void operator<<(unsigned long int val) {}; inline void operator<<(size_t val) {}; }; int main(void) { }My compiler version details:Code:Test.cpp:9: error: ‘void Test::operator<<(size_t)’ cannot be overloaded Test.cpp:8: error: with ‘void Test::operator<<(long unsigned int)’
He and I are both using gcc 4.2.3.Code:Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64- linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
As far as I can tell, the error is because 'size_t' is effectively the same as 'unsigned long'? Should I be able to compile this code, and/or is there some way that I can make it compile (other than removing one of the overloads)? Cheers.
Joe



LinkBack URL
About LinkBacks




CornedBee