Search code examples
c++tensorfloweigen3

the friend class point to a class of the same name in a different namespace


I'm sorry I cannot describe the problem clearly. The error given by the compiler is:

D:\download\tensorflow-master\tensorflow-master\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src\google/protobuf/arena.h(883): error C3855: “Eigen::Map”: type parameter 'MapOption' is incompatible with the declaration
D:\download\tensorflow-master\tensorflow-master\tensorflow\contrib\cmake\build\protobuf\src\protobuf\src\google/protobuf/arena.h(883): error C2976: “Eigen::Map”: too few type arguments

The error comes from the official tensorflow code, and I could run the example program written in C++. While when I try to insert my tensorflow code into my another project, here comes the error.

 template <typename Key, typename T>
 friend class Map;

I know the problem is that the 'Map' point to the Eigen::Map while it needs to point to the google::protobuff::Map. Additionally, the declaration of 'Map' is under the google::protobuff namespace. Did anyone meet the same problem before? I'm trying my best to give a clear statement. Thanks a lot!


Solution

  • That's why you should not:

    1. Use using namespace within scope with declarations

    2. Rely on redefinition of identifiers reserved or used in standard or common libraries

    Both cause conflicts of names and latter able to cause a nundetectable conflict.