Example of using stubbing

Can you please provide an example of using stubbing when integrating code into Mayhem?

In the course of harnessing an application, you may encounter compilation problems complaining of “undefined references” to certain functions. If you are using or testing these functions, it’s best to go and find or include the correct libraries or headers into your harness. However, if you know that you are not using or testing the function that the compiler complains is “undefined”, you can easily get past this by stubbing the function out. For example, if you had an error during compilation such as:

myHarness.cpp:21: undefined reference to 'SuperfluousClass::functionIDontCareAbout()'

you could easily resolve this error by adding that function to the class. Within the class declaration, simply add something like:

char functionIDontCareAbout(char arg1, int arg2) {
      return NULL; //do nothing!

will resolve the compiler error. This is the concept of stubbing: creating a function declaration that solves a compiler warning without necessarily having to implement the function body.