Skip to content

Commit 907fb63

Browse files
committed
Add documentation to document the --preamble argument
Signed-off-by: Ramzi El-khater <[email protected]>
1 parent e34fbb0 commit 907fb63

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,21 @@ You can mark all fakes with the weak attribute like so:
627627
628628
See the example project that demonstrates the above approach: _./examples/weak_linking_.
629629
630+
## Specifying a preamble in the mock funtion name
631+
632+
You can make fff add a preamble to the mock function name by generating fff.h as below
633+
```
634+
ruby fakegen.rb --preamble bar_
635+
```
636+
This will cause the mock of function foo() to be named as bar_foo() for every mocked function foo().
637+
638+
This is useful if one needs to build with the real function included. Note that references to the real function will need to change to refer to the new mock function name, this can be done with the help of linkers.
639+
640+
One example is below,
641+
- Use method described here to name function foo() as __wrap_foo()
642+
- use the GNU linker option -Wl,--wrap foo to re-route all references to foo() to __wrap_foo()
643+
- Set 'foo_fake.custom_fake' field to point to the real version of foo(), this will now be named as __real_foo()
644+
630645
## Find Out More
631646
632647
Look under the examples directory for full length examples in both C and C++.

0 commit comments

Comments
 (0)