Consider this code:
#include <iostream>
template<class C>
struct time { };
int main() { }
It produces (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
include time_t time(time_t*)
?iostream
include time_t time(time_t*)
outside std
namespace?template<class C>
, do I not get this error?
If you run g++ -H -Wall -c testim.cc
(where testim.cc
is your example) you'll see that
.... /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>
is included for pthread support.
This is with GCC 4.6 on Debian/Sid/AMD64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With