How to resolve code generation errors caused by custom TLC file for custom C++ inlined S-Function within referenced model?
I have a custom C++ S-Function "sfun_Timestamp.cpp" that I am calling via an "S-Function" block within my Simulink model "Test_Timestamp.slx" in MATLAB R2021b. I am then calling "Test_Timestamp.slx" as a referenced model in "Test_Timestamp_Global.slx". I have written a custom TLC file "sfun_Timestamp.tlc" to inline my custom S-Function.
Simulating the top-level model "Test_Timestamp_Global.slx" that includes the S-Function inside the referenced model "Test_Timestamp.slx" works correctly. However, I observe the following build error when generating C++ code for "Test_Timestamp_Global.slx":
Component:Simulink | Category:Block diagram warning
### Invoking Target Language Compiler on Test_Timestamp.rtw
### Using System Target File: L:\ML_MATLAB64\R2021b\rtw\c\ert\ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:\ML_MATLAB64\R2021b\rtw\c\tlc\blocks\gensfun.tlc:BlockTypeSetup(585)
[01] L:\ML_MATLAB64\R2021b\rtw\c\tlc\private_api\blocksetuplib.tlc:BlockSetupAndCompatibilityCheck(113)
[02] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\commonpass.tlc:<NONE>(53)
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:\ML_MATLAB64\R2021b\rtw\c\tlc\blocks\gensfun.tlc:BlockInstanceSetup(378)
[01] L:\ML_MATLAB64\R2021b\rtw\c\tlc\private_api\blocksetuplib.tlc:BlockSetupAndCompatibilityCheck(134)
[02] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\commonpass.tlc:<NONE>(53)
.
### Caching model source code
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:\ML_MATLAB64\R2021b\rtw\c\tlc\blocks\gensfun.tlc:Outputs(1558)
[01] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\commentlib.tlc:generateNonExprOutput(178)
[02] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:OpaqueTLCBlockFcn(5025)
[03] L:\ML_WORKSPACE\slprj\ert\Test_Timestamp\tmwinternal\tlc\s1_b0_0zjfs_0_Outputs.tlc:Outputs(7)
[04] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:FcnGenRateGroupedCodeFromModule(5926)
[05] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:FcnGenerateCodeFromModule(5809)
[06] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:SLibFcnGenBodySysFcn(292)
[07] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:SLibFcnGenBodyFcnCache(509)
[08] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\opaquelib.tlc:SLibFcnGenBodySysFcnEntry(667)
[09] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\commonbodlib.tlc:FcnGenBodySysCache(1900)
[10] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\commonbodlib.tlc:SLibGenBodyCache(6478)
[11] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\formatwide.tlc:<NONE>(76)
.
Error: File: sfun_Timestamp.tlc Line: 1 Column: 1
A %implements directive must appear within a block template file and must match the %language and type specified
Main program:
==> [00] L:\ML_MATLAB64\R2021b\rtw\c\tlc\blocks\gensfun.tlc:BlockInstanceData(704)
[01] L:\ML_MATLAB64\R2021b\rtw\c\tlc\blocks\subsystm.tlc:BlockInstanceData(35)
[02] L:\ML_MATLAB64\R2021b\rtw\c\tlc\lib\syslib.tlc:LibCacheBlockInstanceData(6667)
[03] L:\ML_MATLAB64\R2021b\rtw\c\tlc\mw\formatwide.tlc:<NONE>(92)
### Writing header file Test_Timestamp_types.h
### Writing header file Test_Timestamp.h
### Writing source file Test_Timestamp.cpp
.
### Writing header file Test_Timestamp_private.h
### TLC code generation complete.
### Build procedure for Test_Timestamp aborted due to an error.
Build Summary
Code generation targets built:
Model Action Rebuild Reason
=================================================================================================
Test_Timestamp Failed Dependency sfun_Timestamp.tlc of S-function sfun_Timestamp has changed.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 2.464s
Error: Errors occurred - aborting
How can I resolve this build error and generate code?
Respuesta aceptada
0 comentarios
Más respuestas (0)
Ver también
Categorías
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!