A possible workaround to get different external definitions could be to use Customize Build Process with "sl_customization.m". After the hook point "before_make" where all code files from the SImulink model are generated you can place your file handling code and modify the C-code source files by adding MATLAB code to the "STF_make_rtw_hook.m" template file.
To create a custom STF_make_rtw_hook hook file for your build procedure, copy and edit the example ert_make_rtw_hook.m file, which is located in the foldermatlabroot/toolbox/coder/embeddedcoder (open), as follows:
Copy ert_make_rtw_hook.m to a folder in the MATLAB path. Rename it in accordance with the naming conventions described in Conventions for Using the STF_make_rtw_hook File. For example, to use it with the GRT target grt.tlc, rename it to grt_make_rtw_hook.m.
Rename the ert_make_rtw_hook function within the file to match the file name.
Implement the hooks that you require by adding code to case statements within the switch hookMethod statement.
For example, in the "ert_make_rtw_hook.m" which you have copied into the folder where your Simulink model was saved you can add our MATLAB code in the switch/case section "before_make" to open the header file where the /* Model entry point functions */ are defined and modify it with MATLAB Low-Level File I/O functions like fopen(..).
Tip: when you change your custom "ert_make_rtw_hook.m" file code, then run in the MATLAB command window "sl_refresh_customizations" so that the changes are adopted for the next model build.