[p4] Adding a Changelist # to C++ code...?
rtroughton at midway.com
Thu Feb 21 04:23:34 PST 2008
This sounds good. Is there a way to have it automatically generate that
header file, though?
We were previously told by Perforce tech support that the way to get the
changelist number was:-
p4 -c NCE-RTroughton changes -t -m 1 "#have"
However, we were told at the time that this wouldn't be 100% reliable...
but it seems good enough for us, anyway. We've never encountered a
problem using it...
My question, really, is how to use this to create a header... I guess I
could write a little app which takes the output from this and parses
it...? But is there a better way?
Typical output from the above says:-
"Change 56552 on 2008/02/21 08:10_37 by JBlack at NCE-JBlack '[xxxproject]
- [fix] make something work'"
From: Stephen Vance [mailto:steve at vance.com]
Sent: 21 February 2008 11:32
To: Troughton, Robert
Cc: perforce-user at perforce.com
Subject: Re: [p4] Adding a Changelist # to C++ code...?
The typical approach to this is to have your build system generate a
header file with the information in it.
I don't understand your comment about the "hack." Changelist numbers are
unique. As long as you craft your 'p4 changes -m1' command correctly,
you will always get the correct answer. I don't understand what you mean
by "an identical but different changelist."
Troughton, Robert wrote:
> Does anyone know of a way to integrate the last synced version number
> from Perforce into C++ code, such that it can be displayed on screen?
> I suspect that this is impossible... but it's worth asking.
> Basically, if I sync to changelist X and make some changes, I'd like
> app to display on screen that I'm running version X. I know that
> a commandline "hack" to find out the changelist that I last sync'ed to
> (it's a hack because it does a search across the depot so could,
> potentially, report an identical but different changelist). However,
> there a good way to automagically put this changelist number into the
> Has anyone attempted anything similar to this...?
> perforce-user mailing list - perforce-user at perforce.com
More information about the perforce-user