Including time.h header causes VC 7.1 to barf ? ...

A

Alfonso Morra

Hi I'm compiling some code and need to generate some random numbers. To
save time, I decided to use the srand, rand and time functions.

My code worked (atleast built fine) until I added time.h, then the
compiler (VC7.1) barfed up this lot:

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(156) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(158) : error C2065: 'time_t' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(158) : error C3861: 'time_t': identifier not
found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(158) : warning C4229: anachronism used :
modifiers on data are ignored
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(158) : error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(159) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(160) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(161) : error C2143: syntax error : missing ';'
before '__cdecl'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(161) : error C2501: 'time_t' : missing
storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(161) : error C2371: 'time_t' : redefinition;
different basic types
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(166) : error C2143: syntax error : missing ';'
before '__cdecl'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(166) : error C2501: 'time_t' : missing
storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(166) : error C2371: 'time_t' : redefinition;
different basic types
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(166) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(175) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(176) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(177) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(178) : error C2143: syntax error : missing ';'
before '__cdecl'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(178) : error C2501: '__time64_t' : missing
storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(179) : error C2143: syntax error : missing ';'
before '__cdecl'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(179) : error C2501: '__time64_t' : missing
storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(179) : error C2086: 'int __time64_t' : redefinition
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(178) : see declaration of '__time64_t'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(179) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(199) : error C2143: syntax error : missing ','
before '*'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\time.h(206) : error C2143: syntax error : missing ','
before '*'



This is not the first time I have seen the compiler complain about a set
of core (i..e Microsoft supplied) headers. Does anyone know what is
going on?. Is this a bug?

In case anyone was wondering, the code am writing is a one source file
and there are no #defines so I don't think this is due to name
collisions. I will be very grateful to hear from someone who knows the
cause of this.
 
J

Jochen Kalmbach [MVP]

Hi Alfonso!
Hi I'm compiling some code and need to generate some random numbers. To
save time, I decided to use the srand, rand and time functions.

My code worked (atleast built fine) until I added time.h, then the
compiler (VC7.1) barfed up this lot:

For me the following works perfectly:

#include <stdio.h>
#include <time.h>
#include <tchar.h>

int _tmain()
{
return 0;
}


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top