On MAC OSX
, I am trying to compile the following code
#include <list>
int main()
{
std::list<int>::iterator it(0);
return 0;
}
When I run g++ a.cpp -o a
I get
a.cpp:5:27: error: calling a private constructor of class
'std::__1::__list_iterator<int, void *>'
std::list<int>::iterator it(0);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/list:254:14: note:
implicitly declared private here
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
My end goal is to compile this C++ code.
Edit
Is that really gcc? MacOS likes to alias gcc to clang
I think you're right!
$g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
See if this solves your problem (I don't know why clang rejects that standard library implementation's std::list).
mmhh... not really yet. My PATH is
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin
and which gcc
indicate indicates /usr/local/bin/gcc
. I might not fully understand the other answer though.