help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unique identifiers for guard macros


From: red floyd
Subject: Re: unique identifiers for guard macros
Date: Fri, 07 Apr 2006 18:52:11 GMT
User-agent: Thunderbird 1.5 (Windows/20051201)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]