Function caller block generating Function_name.h file in code generation

Hi,
I'm wondring if we can edit the properties of function caller block to define header file in which function is already defined but that file is not inlcuded in matlab file structure.
I have a prototype in function caller block and while generating code it is creating a new function_name.h file. But i already have this function defined in ShadowLib.h file which is in another Visual studio project folder and used while building code in VS 2022 and i cannot include this in matlab folder structure.
While building code in VS the ShadowLib.h file is used as function are defined in that but since matlab is again generating function_name.h files in code then VS is throughing as error prototype redeclared.
In below image a ShadowLib_Save.h file is getting creating in matlab code generation. but this function is already decaled in shadowLib.h file i just want matlab to use shadowLib.h file in header file and use this function in SubSysRef2_CA2SignalLayer.c file withour generating ShadowLib_save.h file.

답변 (1개)

Mark McBroom
Mark McBroom 2025년 9월 15일
If the .c and .h files already exist for the function you want to call, you should use the C Caller block. https://www.mathworks.com/help/simulink/ug/integrate-ccode-ccaller.html

댓글 수: 5

I do have .c and .h files for the functions but i cannot include those files path. Those files are only accessed when generating code on visual studio. For noe i just wanted to know how can i use thode funtions in simulink with the need of .c and .h files and also without generating function_name.h files in code.
I still believe the C Caller block is the best approach. You can not call C functions with the Simuilnk Function Caller block.
to use c caller i need to provide .c and .h files, here in this case i cannot provide these two files. any other approch?
In your problem statement you said that you already have the function defined in ShadowLib.h, that is why I suggested C Caller. Where is your function defined?
it is defined in visual studio project files. I cannot use that file in matlab code generation. After generating code in Matlab and moving generated code to visual studio project, then it can get the definition.
Before that is it possible to just define header file in visual studio project to include in main.c so and call that function in matlab with createing it's own function_Name.h file?

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

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2024b

질문:

2025년 9월 12일

댓글:

2025년 9월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by