考虑这段代码:
#include <iostream>
template<class C>
struct time { };
int main() { }
它产生(GCC 4.5):
error: ‘template<class C> struct time’ redeclared as different kind of symbol
/usr/include/time.h:186:15: error: previous declaration of ‘time_t time(time_t*)’
- 为什么
iostream
包括time_t time(time_t*)
?
- 为什么
iostream
包括time_t time(time_t*)
外部std
命名空间?
- (未答复)为什么,如果我删除
template<class C>
,我没有收到此错误吗?
如果你跑g++ -H -Wall -c testim.cc
(where testim.cc
是你的例子)你会看到
.... /usr/include/c++/4.6/bits/ios_base.h
..... /usr/include/c++/4.6/ext/atomicity.h
...... /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr.h
....... /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h
........ /usr/include/pthread.h
......... /usr/include/sched.h
.......... /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h
.......... /usr/include/time.h
So <time.h>
包含用于 pthread 支持。
这是 Debian/Sid/AMD64 上的 GCC 4.6
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)