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 CCS Technical Support

preprocessor directive __FILE__, how can I find its length

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



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

preprocessor directive __FILE__, how can I find its length
PostPosted: Fri Nov 04, 2005 4:51 am     Reply with quote

I am not sure whether to ask this question of CCS support, hopefully Darren will respond

I am trying to embed the file name into the ROM, and also have the ability to strip specific characters during run time.

its easy to print out in the form :-
printf("Software was compiled on ");
printf(__TIME__ " ");
printf(__DATE__ "\n\r ");
printf(__FILE__ "\n\r ");

and that works fine.

I want to get to each individual character, so I can send just certain characters.

for example, I know that the __TIME__, and __DATE are in a fixed format, so by doing this :-


const byte DATE[]= {__DATE__};
const byte TIME[]= {__TIME__};
const byte FILE[]= {__FILE__};

then

the date is stored in ROM as 30 34 2D 4E 6F 76 2D 30 35 (04-Nov-05)

so extracting it by the following is easy.

i=DATE[0]; // 30 ascii 0
i=DATE[1]; // 34 ascii 4
i=DATE[2]; // 2D ascii -
i=DATE[3]; // 4E ascii N
i=DATE[4]; // 6F ascii o
i=DATE[5]; // 76 ascii v
i=DATE[6]; // 2D ascii -
i=DATE[7]; // 30 ascii 0
i=DATE[8]; // 35 ascii 5


and the same for the TIME.

The problem comes with the __FILE__

This of course is not a fixed length

Is there anyway to get the length of the __FILE string , so that I can do a

i=DATE[n]; // last character in the string.

I really dont want to have to predefine a string buffer of say 100 characters, then transfer it, and work on it as a string in RAM

It would also be useful if the __DATE__ had the option of outputting the month number, rather than the three character letters, so that

APR would become 04


Mike
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Fri Nov 04, 2005 8:44 am     Reply with quote

This may help (hope it does).

http://www.ccsinfo.com/forum/viewtopic.php?t=24422&highlight=file+path
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