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
Here a simple message for giving an idea (with care, I may be wrong and probably not portable idea) but clib functions such as fopen, printf, read, write are weak functions, therefore you can define a function with their name to change their behavior without having to deal by "namespacing" them (fopen => eopen).
I used it on Linux for unit test for example: https://github.com/Lecrapouille/BacASable/tree/master/Cpp/UnitTests with some risk for example, like in my case not restoring the original function and calling code coverage tools that keep using the mocked function and ending by segfault.
The text was updated successfully, but these errors were encountered:
Thanks for the idea! I will have to take a look at this.
The reason why I use a compiler preprocessor directive (to re- #define eopen as fopen), is that it can be easily turned on and off during compile time with a flag. That means that you can use your local filesystem during development, which can change dynamically (without having to embed it first) and embed it quickly at deployment.
Additionally, it lets you use a local and an embedded filesystem simultaneously (in theory - although most use cases would probably use one or the other).
If I were to overwrite the functions with c-embed, then the local file system could not be used unless I removed the c-embed header entirely, which would be a code modification depending on whether you're developing or deploying; one of the main goals of this repo was to avoid this entirely.
First, nice collection of repos :)
Here a simple message for giving an idea (with care, I may be wrong and probably not portable idea) but clib functions such as fopen, printf, read, write are weak functions, therefore you can define a function with their name to change their behavior without having to deal by "namespacing" them (fopen => eopen).
I used it on Linux for unit test for example: https://github.com/Lecrapouille/BacASable/tree/master/Cpp/UnitTests with some risk for example, like in my case not restoring the original function and calling code coverage tools that keep using the mocked function and ending by segfault.
The text was updated successfully, but these errors were encountered: