Search code examples
cc-preprocessoransi-c

ANSI C: standard definition for the size of the __DATE__ and __TIME__ strings?


Is there a standard definition for the size of the __DATE__ and __TIME__ strings in ANSI C?

The motivation behind this question is:

  • I have two applications running on two different CPUs.

  • During runtime, app #1 receives date and time (as part of version-info) from app #2.

  • Of course, app #2 takes them from the preprocessor __DATE__ and __TIME__ definitions.

So I would like to know whether or not I can statically allocate in app #1 an array, into which I can copy the info received from app #2.

Thanks


Solution

  • __DATE__

    The date of translation of the source file (a character string literal of the form "Mmm dd yyyy", where the names of the months are the same as those generated by the asctime function, and the first character of dd is a space character if the value is less than 10). If the date of translation is not available, an implementation-defined valid date shall be supplied.

    __TIME__

    The time of translation of the source file (a character string literal of the form "hh:mm:ss" as in the time generated by the asctime function). If the time of translation is not available, an implementation-defined valid time shall be supplied.