Preventing User Source Code from Being Deleted from
Build Directories
Prior to Release 13 (Version 5.0), the Real-Time Workshop product
did not delete any .c or .h files
that the user had placed in the build directory when rebuilding targets.
From Release 13 onward, all foreign source files are by default deleted
during builds, but can be preserved by following the guidelines given
below.
If you put a .c/.cpp or .h source
file in a build directory, and you want to prevent the Real-Time Workshop product
from deleting it during the TLC code generation process, insert the
string target specific file in the first
line of the .c/.cpp or .h file.
For example,
/* COMPANY-NAME target specific file
*
* This file is created for use with the
* COMPANY-NAME target.
* It is used for ...
*/
...
Make sure you spell the string "target specific
file" as shown in the preceding example, and that the string
is in the first line of the source file. Other text can appear before
or after this string.
In addition to preserving them, flagging user files
in this manner prevents postprocessing them to indent them along with
generated source files. Auto-indenting occurred in previous releases
to build directory files with names having the pattern model_*.c/.cpp (where * could
be any string). The indenting is harmless, but can cause differences
to be detected by source control software that might trigger unnecessary
updates.
 | Custom Code in Subsystems | | Integrating External Code Using S-Functions |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit