You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -627,6 +627,21 @@ You can mark all fakes with the weak attribute like so:
627
627
628
628
See the example project that demonstrates the above approach: _./examples/weak_linking_.
629
629
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
+
630
645
## Find Out More
631
646
632
647
Look under the examples directory for full length examples in both C and C++.
0 commit comments