Code Generation folder for C/C++ code block
显示 更早的评论
Hello,
I am using the C/C++ code block to include some custome C code in my model. I am buiilding the code by using the "Build" button pictured below:

This works fine and produces a C source file.
My issue is when I CodeGen I have to manually include this Custom Code file in the folder each time (it gets deleted otherwise).
I am curious is there a way to control where this C/C++ codeblock builds its file and how I can have that build location to be the same as CodeGeneration ? Right now the C/C++ function always builds to the root directory of my simulink project.
3 个评论
Piyush Kumar
2024-4-30
Hi Jake,
Check this link - https://in.mathworks.com/help/simulink/ug/specify-configure-custom-c-code.html#mw_ac59cae5-336f-43f8-9b07-fbdcbc500b57
In the "Specify Custom Code Settings for Code Generation" section of above link, you will find that there are options available like "Include directories", "Source files*" etc.
Is the "C/C++ code block" part of the same Simulink model for which you are generating code using "Simulink Coder"?
Jake Gareau
2024-4-30
Mark McBroom
2024-5-19
You do not need to place the custom code in the CodeGen folder ... in fact you should not place it there, as it will get deleted when you regenerate code for your model. Place the .c and .h files in a different folder and then:
- In the "Include Directories" section of the custom code, specify the path to your header file
- In the "Source Files" section, specify the full/relative path to your C files ( for example c:/work/src/ABC.c )
Thanks.
Mark.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!