liveBook · Manning

__TIME__

As explained in Modern C, Third Edition

__TIME__ is a predefined C macro that expands to a string literal containing the time of translation.

__TIME__ is a predefined C macro that expands during translation to a string literal containing the translation time. For example, printing puts(__TIME__) displays the time associated with that translation, rather than obtaining a time while the program runs. section 17.3

Use __TIME__ with the same type awareness required by other predefined context macros:

  • Treat its expansion as a string when passing it to a function such as puts or fprintf. section 17.3
  • Distinguish translation-time context from runtime calendar-time interfaces such as time and difftime. section 8.6 section 17.3

How Modern C, Third Edition covers it

How deep it goes
Defines the expansion as a string literal containing translation time but does not specify its representation or formatting.
Examples
Uses diagnostic output and contrasts translation-time macros with runtime interfaces such as time and difftime.
What it assumes
Assumes familiarity with C macros, string literals, and formatted output.
What you can do after
Apply __TIME__ in diagnostic output while recognizing that it records translation context rather than runtime time.
How it connects
Connects predefined macros with debugging, diagnostic output, __DATE__, __FILE__, __LINE__, and __func__.

Also explained in

Compare how 2 books explain __TIME__ →

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.