For the benefit of everyone, please find below Matlab team answer:
"First of all, I would like to make you aware of the proper way to replace the names used in code generation with custom names. In order to do so, you need to open the Configuration Parameters window, then navigate to the section "Code Generation>Data Type Replacement" and then check the box "Replace data type names in the generated code". Upon doing so, you will be able to insert a "Replacement Name" for each "Code Generation Name".
Unfortunately, you are not allowed to insert C keywords in those boxes. For instance, upon trying to insert "double" on the line corresponding to "real_T" (or any other line), the error "double is a C keyword and cannot be used as a replacement type" is shown. After consulting the development team, I have been made aware that there are multiple valid reasons why using C reserved keywords for Data Type Replacement is forbidden. Just as a matter of example, which I provide you informally, some reason is explained here.
Therefore, it looks like you have now two options to workaround this (outside of MATLAB):
- You can include the "rtwtypes.h" file (that we generate in the subfolder "slprj\ert\_sharedutils") in your compilation process (via your Qt project file).
- You can specify valid names for all your types in the Data Type Replacement pane (as I explained in the previous paragraph), and then "typedef" them in the C++ class (in Qt) that will make use of the generated code.
I would not exclude, as a third alternative option, that you can write a simple script that parses the whole generated source code and substitutes each of occurrence of "real_T" with "double" and the likes.
I hope that this hints can help you achieve what you want, since MATLAB does not offer the feature you described, for good reasons, as I wrote. Hence, I will now mark the case as closed with provided workaround."