c++模板在GCC中工作正常,但在LLVM-GCC编译器中显示编译时错误
C++ template working fine for GCC but showing compile time error in LLVM-GCC compiler
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)
我猜你的真正的问题在别处。
相关文章:
- 带有引用的std::tuple在clang中编译失败,但在gcc中编译失败
- 为什么以下代码在在线 ide(gcc 7.2.0) 上有效,但在 ubuntu 上出现错误?
- 我可以在Windows(Visual C++)中读取bin文件,但不能在linux(GCC)上读取bin文件
- enable_if is_same constexpr函数使MSVC失败(但在Clang,GCC中效果很好)
- 为什么一些 GCC 警告标志不属于C++语言,但在C++中工作
- 从std::map派生的类不在Visual C++上编译(但在gcc和clang上编译)
- GCC/Clang上的模板错误,但在MSVC上没有错误
- 带有可变参数的嵌套宏在GCC中编译,但在MSVC中不编译
- 为什么这段代码在Visual Studio中有效,但在gcc中失败
- 作为模板非类型参数的 C 字符串在 gcc 6.3 中有效,但在 Visual Studio 2017(x64 为 19
- gcc linker - .obj dump 具有混合源代码程序集,但在 .elf 中链接时没有
- 成员函数模板不会在 clang 上编译,但在 GCC 上编译
- 在 gcc 4.4 上"pure virtual function called",但在较新版本或 clang 3.4 上不
- GCC 中的编译器错误,但在将 decltype 与具有尾随返回类型语法的模板化成员函数一起使用时没有 clang
- 构造函数上的SFINAE在VC2017中工作,但在clang / gcc中不起作用
- c ++ 11 参数包在 Apple LLVM 7.0.0 中存在错误行为,但适用于 GCC-5.1
- 依赖模板可以在Visual Studio中编译,但在clang/gcc中失败
- c++模板在GCC中工作正常,但在LLVM-GCC编译器中显示编译时错误
- 在我的项目中使用预编译的头(clang/llvm,但也使用gcc).如何在make中部署-include选项
- c++标准库在.mm文件中找到,但在.h文件中找不到(Xcode 4.5 LLVM GCC 4.2)