Reputation: 523
My laptop can not compile a simple c++ code since yesterday, it works perfectly fine before.
The c++ code is can be a hello-world code in main.cpp file.
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout<<"Hello World"<<endl;
return 0;
}
I am trying to compile the code by
icpc main.cpp
The error information is
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm(637), from /Library/Developer/CommandLineTools/usr/include/c++/v1/__string(56), from /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view(171), from /Library/Developer/CommandLineTools/usr/include/c++/v1/string(470), from /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale(15), from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios(216), from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream(38), from main.cpp(1): /Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits(2065): error: expected an identifier : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
compilation aborted for main.cpp (code 2)
A few information:
I am using icpc (ICC) 17.0.4 20170411, it is installed from Intel® Parallel Studio XE Composer Edition for C++ macOS.
My mac is MacBook Pro (15-inch, 2017), version 10.12.6.
If I use gnu compiler, it works fine. While my code needs to use intel's compiler.
The code works before, do not know while it becomes this. I have already tried restarting the systems.
======================================================================
Update1: The problem happened after I update my "Command Line Tools for Xcode". It looks like the /Library/Developer/CommandLineTools/usr/include/c++/
is not right.
======================================================================
Update2: This is can be solved by using icpc -std=c++11 main.cpp
However when I change my main.cpp to
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
tuple<vector<int>, vector<int>, vector<int>>
getAllBlockMeanErrorTuple(const vector<int> &vec)
{
vector<int> fact, mean, err;
fact.resize( vec.size() );
mean.resize( vec.size() );
err.resize( vec.size() );
return make_tuple(fact, mean, err);
}
int main(int argc, char** argv)
{
cout<<"Hello World"<<endl;
return 0;
}
It has error again even if I use icpc -std=c++11 main.cpp
/Library/Developer/CommandLineTools/usr/include/c++/v1/__tuple(401): error: type name is not allowed
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
detected during:
Upvotes: 2
Views: 1576
Reputation: 121
I encountered the same issue while upgrading command line tools to the version of September 2017
While not finding a proper solution, I reinstalled previous version ( April 2017) of command line tools and it solved the problem (https://developer.apple.com/download/more/#).
I am looking forward to having a clean solution.
EDIT (5/12/17):
I solved the issue by recompiling everything using gcc. At compilation, Intel compilers will use the compiler that responds to gcc
and g++
in the path. An installation with homebrew and some symlink in /usr/local/bin
pushes the newly installed gcc
in front of clang and then avoids gcc to change at each system update. Hope it helps.
Upvotes: 3
Reputation: 783
Try to check that you are using right settings and GNU is working because it automatically set to C++ try to set compiler to c++ hope this works. OR You can use xcode to write c++ Code.
Upvotes: 0