Code Generation folder for C/C++ code block

조회 수: 2 (최근 30일)
Jake Gareau
Jake Gareau 2024년 4월 24일
댓글: Mark McBroom 2024년 5월 19일
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
Jake Gareau
Jake Gareau 2024년 4월 30일
Hello Piyush,
Thanks for your comment.
The C/C++ block is part of my model, I am generating code using embedded coder.
The generated code references the custom code just fine, I would just like to avoid the manual process of having the place the custom code in the CodeGen folder each time.
The requirement for my project is all the neccessarry code be placed in a specific folder, it does not work to just have include paths to the directory.
and to be clear all the custom code is already included inside the C function block.
Mark McBroom
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:
  1. In the "Include Directories" section of the custom code, specify the path to your header file
  2. In the "Source Files" section, specify the full/relative path to your C files ( for example c:/work/src/ABC.c )
Thanks.
Mark.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by