Platform-independent GUID generation in C++?

Moses Schwartz picture Moses Schwartz · Feb 12, 2009 · Viewed 61.5k times · Source

What is the best way to programmatically generate a GUID or UUID in C++ without relying on a platform-specific tool? I am trying to make unique identifiers for objects in a simulation, but can't rely on Microsoft's implementation as the project is cross-platform.

Notes:

  • Since this is for a simulator, I don't really need cryptographic randomness.
  • It would be best if this is a 32 bit number.

Answer

Anonymous picture Anonymous · Feb 12, 2009

If you can afford to use Boost, then there is a UUID library that should do the trick. It's very straightforward to use - check the documentation and this answer.