[p4] Perforce keyword expansion

Arnt Gulbrandsen arnt at gulbrandsen.priv.no
Tue Dec 4 05:03:24 PST 2001


"Schlueter, Michael" <Schlueter at secunet.de>
> Hi,
> I just found out that the perforce keyword expansion even replaces the
> keywords normal c++ constant strings. It took me quite while to find out
> that somewhere in a parser syntax definition a $date$ was replaced by the
> current date. Is this a bug or feature? 

It's a feature, usually used like this:

const char ident[] = "$Id$";

Many unix machines have a program called 'ident' that will print the
version strings that went into a linked executable.

> Is there a way to avoid this?

Not short of turning off keyword expansion. Perforce doesn't know c++
syntax (or that of any other language, AFAIK).

I have been troubled by it a few times. ISTR I once had a function that
searched for "$Id$" and of course that function's search string got
changed. But it's never been very difficult to work around the problem.

If you're using plain C++, maybe you can use the preprocessor's string
concatenation: "$Da" "te$" is the same as "$Date$".

--Arnt



More information about the perforce-user mailing list