Linkage of templates
I would like to share observation of another non standard behavior found in Visual Studio compiler. According to C++ Templates Complete Guide: “class templates cannot share a name with a different kind of entity”, below code:
int X; template class X { };
gives following error with g++ 4.9:
main.cpp:8:7: error: 'template struct X' redeclared as different kind of symbol
class X {
^
main.cpp:6:5: note: previous declaration 'int X'
int X;
but with VS2013 compiles just fine.
Leave a Reply