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

StackOverflow https://stackoverflow.com/questions/20923970

  •  24-09-2022
  •  | 
  •  

سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top