CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Exporting __DATE__ and __TIME__

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
AdamWebber



Joined: 18 Jun 2014
Posts: 13

View user's profile Send private message

Exporting __DATE__ and __TIME__
PostPosted: Tue Aug 11, 2015 9:39 am     Reply with quote

I am currently exporting the HEX file with the date compiled in the filename. The problem that I currently face is that I need to define the date manually. If I attempt to define the date as:

#define DATE __DATE__

it throws the quotation marks into the mix and Windows hates quotation marks in filenames.

So here is my current operational code:
Code:
#define DATE   11_AUG_2015

#define EXPNAME(a,b,c) a ##b ##c

#export (HEX, FILE = EXPNAME(MY_FILENAME_,DATE,.hex))


What I would like to use is the following:
Code:
#define DATE   __DATE__

#define EXPNAME(a,b,c) a ##b ##c

#export (HEX, FILE = EXPNAME(MY_FILENAME_,DATE,.hex))


Is there a way to remove the quotation marks from the date using the macro #define or any other method so that I can put the date automatically into the filename?
Ttelmah



Joined: 11 Mar 2010
Posts: 19382

View user's profile Send private message

PostPosted: Tue Aug 11, 2015 11:08 am     Reply with quote

I'd say 'no'. Hopefully somebody will prove me wrong now!...

The value returned by __DATE__, is a string. Hence easy to use in things like printf. Now a macro argument can be converted to a string (# does this), hence it is sometimes referred to as the 'stringifying' operator. You'd need a 'de-stringifying' operator, but I don't think one exists.
AdamWebber



Joined: 18 Jun 2014
Posts: 13

View user's profile Send private message

PostPosted: Wed Aug 12, 2015 11:06 am     Reply with quote

Thanks for the info. I can't say that I was very positive in finding a solution as I didn't expect a solution to be available. My cohort and I were trying to find a method but we became stumped. But if anyone else can think of something, it would be welcome and appreciated.
jeremiah



Joined: 20 Jul 2010
Posts: 1329

View user's profile Send private message

PostPosted: Thu Aug 13, 2015 2:24 pm     Reply with quote

What I do is stick to a numeric version:
Filename_YYYYMMDD.hex

I know it isn't exactly what you want but I like how it sorts alphabetically.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group