我有以下结构的代码(实际上当然要复杂得多,特别是"Base"是一个三线程,但我试图捕捉它的要点):
template <class T>
class A {};
template <class T>
class B {
public:
B(){};
};
template <class T>
class C : public B<A<T>> {
public:
using Base = B<A<T>>;
using Base::B;
};
static const C<int> c{};
Run Code Online (Sandbox Code Playgroud)
代码用g ++编译好
g++ -c test.cpp -std=c++11
Run Code Online (Sandbox Code Playgroud)
但是,使用clang ++我收到一条错误消息,我真的不明白
clang++ -c test.cpp -std=c++11
Run Code Online (Sandbox Code Playgroud)
test.cpp:14:14:错误:依赖使用声明解析为使用Base :: B键入不带'typename';
我的代码有什么问题或者这是clang中的错误吗?
注意:在编写using B<A<T>>::B;它时,编译器编译很好,但这不是我的问题的真正解决方案.
编辑:clang版本是3.5.0,gcc版本是4.9.2
我正在使用Docker容器(thewtex/cross-compiler-linux-armv7)在系统上交叉编译一个简单的"Hello World"Linux用户空间C程序x86_64.目标系统是ARMv7嵌入式系统(特别是具有库存固件的Kobo Aura HD电子阅读器).
程序(hello_world.c)的源代码如下
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Hello World!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
出乎意料的是,我可以在主机系统上执行生成的可执行文件:
andreas@andreas-pc:~/tmp/test$ uname -a && ./hello
Linux andreas-pc 4.5.5-201.fc23.x86_64 #1 SMP Sat May 21 15:29:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Hello World!
Run Code Online (Sandbox Code Playgroud)
以及目标设备上
[root@(none) onboard]# uname -a && ./hello
Linux (none) 2.6.35.3-850-gbc67621+ #1038 PREEMPT Thu Apr 25 15:48:22 CST 2013 armv7l GNU/Linux
Hello World!
Run Code Online (Sandbox Code Playgroud)
这有什么解释吗?
作为参考,我使用以下命令集调用编译器
docker run thewtex/cross-compiler-linux-armv7 > ./dockcross.sh
chmod +x dockcross.sh
Run Code Online (Sandbox Code Playgroud)
由于某种原因,生成的shell脚本是错误的,我手动必须替换 …