Mail Archives: djgpp/1999/04/09/19:00:37
Andrew Davidson wrote:
>
> How do the __DATE__ and __TIME__ defines actually work? I've scoured all the
> header files I could lay my hands on but I can't find them anywhere. Are
> there any other similar functions?
These are ANSI C standard macros whose values are determined at compile
time. Compile
printf("%s\n", __DATE__);
on April 1, 1999, and the executable will print "Apr 1, 1999" (or some
such, depending on the locale and the brand of the compier) every time
you execute it, even 10 days later.
The same thing goes for __TIME__ (and __FILE__, __LINE__, and
__STDC__). Try:
printf("%s\n", __TIME__);
printf("%s\n", __FILE__);
printf("%d\n", __LINE__); <-- notice the %d
printf("%d\n", __STDC__); <-- notice the %d
The __FILE__ and __LINE__ macros are useful in debugging to see the
actual execution path.
--
Weiqi Gao
weiqigao AT a DOT crl DOT com
- Raw text -