c++模板在GCC中工作正常,但在LLVM-GCC编译器中显示编译时错误

C++ template working fine for GCC but showing compile time error in LLVM-GCC compiler

本文关键字:但在 LLVM-GCC 编译器 编译时错误 显示 GCC 工作 c++      更新时间:2023-10-16
typedef char TCHAR;
template <class T> class MyTemplateString
{
};
template <class T> class MyList
{
};
typedef MyTemplateString<TCHAR>         MyString;
MyList<MyString> outlist;// here it's showing compile time error

错误是:

模板MyList <MyTemplateString<char>>的隐式实例化

上面发布的代码在这里使用g++和llvm-g++都可以很好地编译,没有任何错误或警告:

$ g++ -Wall -c template.cpp 
$ llvm-g++ -Wall -c template.cpp 

版本信息:

$ g++ -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~123/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
$ llvm-g++ -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/llvmgcc42/llvmgcc42-2335.9~9/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --enable-llvm=/var/tmp/llvmgcc42/llvmgcc42-2335.9~9/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.9)

我猜你的真正的问题在别处。

相关文章: