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*)’
- Why does
iostreamincludetime_t time(time_t*)? - Why does
iostreamincludetime_t time(time_t*)outsidestdnamespace? - (unanswered) Why, if I remove
template<class C>, do I not get this error?
If you run
g++ -H -Wall -c testim.cc(wheretestim.ccis your example) you’ll see thatSo
<time.h>is included for pthread support.This is with GCC 4.6 on Debian/Sid/AMD64