[p4] Adding a Changelist # to C++ code...?

Robert Cowham robert at vaccaperna.co.uk
Thu Feb 21 03:12:46 PST 2008


There are some older threads on this subject on this list - have a search of
the archives.

One way is to do this as part of your build process:

A belt and braces way, assuming you are in root of workspace:

Get the output of "p4 changes -m 1 -s submitted ...#have" - this gives you
changelist in your workspace rather than whole repository (say 1234)

Ensure that the output of "p4 sync -n ... at 1234" is empty meaning you are
cleanly synced to that changelist.

(There are variations on the above - see threads)

Once you have the changelist no, pass that in to compiler has a #define on
the command line, e.g. with -D or /D option depending on your compiler.

Does that help?

Robert

> -----Original Message-----
> From: perforce-user-bounces at perforce.com 
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of 
> Troughton, Robert
> Sent: 21 February 2008 08:19
> To: perforce-user at perforce.com
> Subject: [p4] Adding a Changelist # to C++ code...?
> 
> 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 our app to display on screen that I'm running 
> version X. I know that there's 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, is there a good way to automagically put this 
> changelist number into the sourcecode?
> 
>  
> 
> Has anyone attempted anything similar to this...?
> 
>  
> 
> Robert
> 
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com 
> http://maillist.perforce.com/mailman/listinfo/perforce-user
> 



More information about the perforce-user mailing list