Sean Lynch
Sean Lynch

Reputation: 2983

c++ shared_ptr error with intel 12.1.3

With gcc 4.6.1 I use the following typedef

typedef std::shared_ptr<A> A_Ptr;

I included <memory> and compile it with -std=c++0x and all is fine.

With intel 12.1.3 the same code also compiled with -std=c++0x gives the error

test_intel_gcc.cpp(7): error: qualified name is not allowed
  typedef std::shared_ptr<A> A_Ptr;

Here is a minimal example:

#include <memory>

class A;

typedef std::shared_ptr<A> A_Ptr; 

class A {
public:     
  A() {}
};

int main(int argc, char *argv[]) {
  A_Ptr ap;
  return 0;
}

Upvotes: 4

Views: 2771

Answers (1)

Jonathan Wakely
Jonathan Wakely

Reputation: 171303

The EDG front end (which the Intel compiler uses) gives that error when you use an undeclared, qualified name in a typedef. So it implies std::shared_ptr is not declared in <memory>, which implies either you forgot to use -std=c++0x (but you say you used that) or your Intel compiler is using the headers from an older version of GCC (not your 4.6.1 installation) which doesn't provide shared_ptr.

You should be able to verify you get the same error by changing the template-id to one that definitely isn't declared:

#include <memory>

class A;

typedef std::xxx_shared_ptr<A> A_Ptr; 

Upvotes: 3

Related Questions