Does Creator support preprocessor macros __DATE__ and __TIME__ ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaSa_2723681
Level 2
Level 2
5 replies posted Welcome! First question asked

Hello,

I have seen other compilers, like IAR, support preprocessor macros__DATE__ and __TIME__. __DATE__ is a preprocessor macro that expands to the current date (at compile time) in the form mmm dd yyyy (e.g. "Jan 14 2012"), as a string. The __DATE__ macro can be used to provide information about the particular moment a binary was built. The __TIME__ macro gets the current time of the build.  I think the answer is no but wondering if there is something like this available so my C code could access to when it was built.

Thanks,

Mark

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

PSoC Creator supports  __DATE__ and  __TIME__ preprocessor macros. You can use them to obtain the compilation date and time.

View solution in original post

0 Likes
4 Replies
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

PSoC Creator supports  __DATE__ and  __TIME__ preprocessor macros. You can use them to obtain the compilation date and time.

0 Likes

Thank you GeonaM_26!

Sure enough, this works:

DBG_PRINTF("\n%s %s", __DATE__, __TIME__);

I went to find the address of these string constants and this works too.

DBG_PRINTF("%p\n", (void*) __DATE__); //Prints address of string constant

DBG_PRINTF("%p\n", (void*) __TIME__);

I used the memory viewer and they were there in flash.

Another question: Where are these string constants documented?

They don't seem to be defined anywhere. I wonder what else I am missing.

Cheers!

Mark

0 Likes

These are standard predefined macros. Please goto https://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html#Predefined-Macros for more details.

0 Likes

That is so cool. I had no idea. Live and learn.

0 Likes