【发布时间】:2015-07-18 10:50:05
【问题描述】:
#include <stddef.h>
template<size_t N = sizeof(void*)> struct a;
template<> struct a<4> {
enum { b };
};
template<> struct a<8> {
template<int> struct b {};
};
enum { c, d };
int main() {
a<>::b<c>d;
d;
}
我有一段代码通过 gcc 成功编译为 x64 架构。但失败并出现-m32 错误:
$ g++ -m32 test.cpp
test.cpp: In function ‘int main()’:
test.cpp:16:12: warning: comparison between ‘enum a<4u>::<anonymous>’ and ‘enum<anonymous>’ [-Wenum-compare]
a<>::b<c>d;
^
collect2: error: ld returned 1 exit status
这段代码有什么问题?
【问题讨论】:
标签: c++ templates g++ 32bit-64bit