Need compile-time date string in C++ file in XCode ...
Need compile-time date string in C++ file in XCode ...
- Subject: Need compile-time date string in C++ file in XCode ...
- From: Jay Reynolds Freeman <email@hidden>
- Date: Fri, 5 Jan 2007 16:44:41 -0800
I would like to give my program access to a string that shows the
date it was compiled. If I build in the Terminal shell, I can use
something like
g++ -D DATE=`date` ...
to create a preprocessor definition that contains a date string, and
use it via something like
char releaseDate[] = DATE;
That works the way I expect it to when compiling in Terminal; when
I (eg) printf releaseDate, I get (eg) Fri Jan 5 16:14:51 PST 2007,
and yes, that works even if there are no double-quotes around "DATE".
I would like to make the same kind of string available to a Cocoa
application built in XCode. (XCode 2.4.1, Macbook, OS X 10.4.8).
So I open up the inspector for my build target and try adding
something to the "preprocessor macros" setting in the "Build"
section of the inspector. What I put in is the text
DATE=`date`
separated by blank spaces from other macros that are there.
It doesn't work. what appears where I was expecting, e.g.,
"Fri Jan 5 16:14:51 PST 2007"
is instead the literal text (in a ".i" file -- it won't compile)
`date`
That is, the program acts as if the build process doesn't know
to access the Unix "date" utility. I am probably making a simple
mistake somewhere; can anyone advise me?
I suppose I could always arrange for a compile-time script to
create a C++ file containing the appropriate text, but I don't
know how to make sure that that script runs before the C++ stuff
compiles, so the program gets the newest version number.
Thanks for putting up with a beginner ...
-- Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden