ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
I have the following code that compiles with g++ (4.3.2) without any warning and runs smoothly with "-ansi -pedantic -Wall". But it does not compile with Intel C++ compiler (icc, v10.1). The following is the code:
Code:
#include <iostream>
using namespace std;
class Add {
private:
int dx;
public:
Add() : dx(0) {}
Add(int _dx) : dx(_dx) {}
int operator() (int n)
{
return n+dx;
}
};
int main()
{
Add add_0;
Add add_5(5);
cout << add_0(100) << endl;
cout << add_5(100) << endl;
return 0;
}
The error with icc is:
Code:
/usr/include/c++/4.3.2/bits/char_traits.h(266): error: identifier "__builtin_memchr" is undefined
{ return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); }
^
/usr/include/c++/4.3.2/bits/char_traits.h(270): error: identifier "__builtin_memmove" is undefined
{ return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); }
^
/usr/include/c++/4.3.2/bits/allocator.h(143): error: identifier "__is_empty" is undefined
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/allocator.h(143): error: function call is not allowed in a constant expression
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/allocator.h(143): error: type name is not allowed
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/allocator.h(160): error: identifier "__is_empty" is undefined
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/allocator.h(160): error: function call is not allowed in a constant expression
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/allocator.h(160): error: type name is not allowed
template<typename _Alloc, bool = __is_empty(_Alloc)>
^
/usr/include/c++/4.3.2/bits/locale_facets.tcc(1284): error: class "std::ctype_byname<char>" is not an entity that can be instantiated
extern template class ctype_byname<char>;
^
/usr/include/c++/4.3.2/bits/locale_facets.tcc(1319): error: class "std::ctype_byname<wchar_t>" is not an entity that can be instantiated
extern template class ctype_byname<wchar_t>;
^
compilation aborted for function_objects.cpp (code 2)
Because I was not sure if it was something that conforms to C++ standards (despite -ansi -pedantic -Wall). This was the first time I used something like x(0) which I did not see earlier in the material I read to be a proper way to initialize.
The problem is not something to do with the conformance with standard c++ syntax but about the wrong includes your icc is reading. Post this problem to the icc support so that they can help with your problem.
Have you tried with icpc (the intel C++ compiler)? If I try to compile it using icc I get a catastrophic error, whereas using icpc it compiles without a glitch.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.