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

好久不见. 提交于 2019-12-04 04:58:21

问题


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


回答1:


__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.




回答2:


ISO/IEC 9899:2011, §6.10.8.1 Mandatory macros

__DATE__ The date of translation of the preprocessing translation unit: 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 preprocessing translation unit: 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.

It is very straight-forward, therefore.



来源:https://stackoverflow.com/questions/20923970/ansi-c-standard-definition-for-the-size-of-the-date-and-time-strings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!