Hi Roman,
It is my understanding that you are generating C code from MATLAB code that contains a “typecast” function.
The generated C code uses “string.h” and “memcpy” function, which you want to avoid.
Also, setting the options to the following value did not help;
- “Use memcpy for vector assignment”: No
- “Use memset to initialize floats and doubles to 0.0”: No
As a workaround, the Code Replacement Library (CRL) can be used.
Please follow the workflow mentioned below to achieve the same.
Creating Code Replacement Library for "memcpy"
- Download the attached scripts "crl_table_memcpy.m" and "rtwTargetInfo.m" and save them in the current working directory or in the folder that is in MATLAB Path.
- To use your code replacement library, refresh your current MATLAB session with the command:
>> sl_refresh_customizations
3. Verify the code replacement library by executing the command
>> crviewer('CRL for memory function replacement')
Code generation
- In Generate Code stage of code generation using MATLAB Coder App, open more settings, and set the options' value as below;
a. “Code replacements”: Yes
b. “Code replacement library”: CRL for memory function replacement
2. Generate the code
After using Code Replacement Library, it can be observe that “memcpy” is replaced with “my_memcpy”;
Below are the links to detailed documentation of the steps mentioned above;
Hope this helps!
Regards,
Shivam Malviya