September 2018
Intermediate to advanced
606 pages
14h 32m
English
We will need two source files, both very similar to the previous recipe. One will be configured with the recorded hash (version.hpp.in), as follows:
#pragma once #include <string>const std::string GIT_HASH = "@GIT_HASH@";
We will also need an example source file (example.cpp), which will print the hash to the screen:
#include "version.hpp"#include <iostream>int main() { std::cout << "This code has been configured from version " << GIT_HASH << std::endl;}
This recipe also assumes that we are in a Git repository with at least one commit. So, initialize this example with git init, and create commits with git add <filename>, followed by git commit, in order to get a meaningful example.
Read now
Unlock full access