How to use hash.exe

This walkthrough introduces you to hash.exe and shows you how to use it with The Machinery.

You will learn about:

How to use hash.exe and TM_STATIC_HASH

While working with The Machinery, you will have surely noticed that its systems often expect a hashed version of a string as input. In this document, we will be dealing with static hashes defined with TM_STATIC_HASH to identify, for example, a type in our data model, The Truth. If you are searching documentation on runtime hashes, you’ll want to check out the murmurhash64a.inl files.

In this document, we will be using hash.exe to generate new hash values or update the changed ones. The hash.exe utility checks the entire source code and makes sure that wherever you use TM_STATIC_HASH, the numeric value v matches the actual hash of the string s (if not, the code is updated). If you do not run the executable before you build, you will have compile errors.

Note: tmbuild has the option to run hash.exe before it builds. tmbuild --gen-hash.

Let us look at where this tool is useful and is being used a lot: In The Truth.

For example, When defining Truth Objects or Types, we are using this tool to hash the name of the type statically


#define TM_TT_TYPE__ASSET "tm_asset"

#define TM_TT_TYPE_HASH__ASSET TM_STATIC_HASH("tm_asset", 0xca71127abbb72960ULL)

enum {

 TM_TT_PROP__ASSET__NAME = 0, // string


 TM_TT_PROP__ASSET__UUID_TAGS, // subobject_set(UINT64_T) storing the UUID of the associated tag.

 TM_TT_PROP__ASSET__OBJECT, // subobject(*)



In the above example we have the definition of the Truth Type tm_asset. The #define TM_TT_TYPE_HASH__ASSET TM_STATIC_HASH("tm_asset", 0xca71127abbb72960ULL) was generated by the hash utility. Before the tool ran the code looked similar to this: #define TM_TT_TYPE_HASH__ASSET TM_STATIC_HASH("tm_asset")

For example later on we can use it to create an object of this type. If we do not have the corresponding type id tm_tt_type_t we need to ask The Truth:

tm_the_truth_api->object_type_from_name_hash(tt, TM_TT_TYPE_HASH__ASSET);