Ulrich Eckhardt wrote:
Angel Tsankov wrote:
Can someone recommend a way to create "unique" identifiers for use
in guard macros:
#if !defined (UNIQUE_GUARD)
#define UNIQUE_GUARD
As you said, the most important thing is to not collide with any existing
one. The advise to use a GUID is a good one, another good one is to just
use the date when the file is started. I always leave a generic prefix
like the module and the filename in uppercase (just in case I need to
identify where it's coming from).
BTW: you asked for a GUID tool - depending on the system you have, you
don't need one, on most unixoid systems you can do this:
dd if=/dev/urandom count=1 bs=10 | md5sum
This reads ten bytes from a random-number generator and computes their MD5
hash - should be sufficiently unique. ;)
Oh, that's a GOOD one! I hadn't thought of that!
$ dd if=/dev/urandom count=1 bs=10 2> /dev/null | md5sum
d3474a0dc64708f0fe72817980f7faf5 *-
#ifndef FILE_H_d3474a0dc64708f0fe72817980f7faf5
#define FILE_H_d3474a0dc64708f0fe72817980f7faf5
// yada yada yada
#endif // include guard for file.h
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus