Level-2 S-Function doesn't compile after exporting code with Embedded Coder - 'mwSize' type unknown

조회 수: 15 (최근 30일)
Hi,
I have a non-inlined Level-2 S-Function that I'm trying to integrate in my project. I want to generate the code with Embedded Coder and integrate the resulting C-Code in a broader C Project.
Before adding the S-Function-Block, this worked fine but now, it cannot compile the S-Function .c-File.
I'm getting this compilation error:
aarch64-none-elf-gcc -D_PLATFORM_WRDCU_20 -DRT -DEXT_MODE=0 -DXCP_CUSTOM_PLATFORM -D_3CORE_ -DFW_VERSION=000_Test -D_RELEASE_ -Wall -O2 -IC:/workspace/WS/SW/shared/linux/include/kk-softwatchdog -IC:/workspace/WS/SW/Control/src -IC:/workspace/WS/SW/Control/src/AlmMgt1_SOKZ -IC:/workspace/WS/SW/Control/src/enercon -IC:/workspace/WS/SW/Control/src/lib_eth -IC:/workspace/WS/SW/Control/src/MEPA1_SOKZ -IC:/workspace/WS/SW/Control/src/SL_NG-DTC -IC:/workspace/WS/SW/Control/src/unit_tests -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/CCnv1_SOKZ -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/B2B_GenPowerControl -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/contrGridCur -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/FACTS20_PC_CPU2_FrequenzMess -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/grid_analyzer -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/kalman_ceval -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/NGDTC_CU_CPU_Int -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/PlToPs_unpack -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/PQ_control -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/PsToPl_pack -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/statemachine -IC:/workspace/WS/SW/Control/src/SL_NG-DTC/slprj/sok_zynq/_sharedutils -IC:/workspace/WS/SW/Control/src/enercon/can -IC:/workspace/WS/SW/Control/src/enercon/Fehlerliste -IC:/workspace/WS/SW/Control/src/enercon/HwDriverApp -IC:/workspace/WS/SW/Control/src/enercon/System -IC:/workspace/WS/SW/Control/src/enercon/System/Ethernet -IC:/workspace/WS/SW/Control/src/enercon/System/Firmware -IC:/workspace/WS/SW/Control/src/enercon/System/Serial -IC:/workspace/WS/SW/Control/src/enercon/System/UserInterface -IC:/workspace/WS/SW/Control/simulink_include -IC:/workspace/WS/SW/shared/Common/inc -IC:/workspace/WS/SW/shared/Common/src/lib_axi -IC:/workspace/WS/SW/shared/Common/src/lib_can -IC:/workspace/WS/SW/shared/Common/src/lib_confmon -IC:/workspace/WS/SW/shared/Common/src/lib_icc -IC:/workspace/WS/SW/shared/Common/src/lib_logger -IC:/workspace/WS/SW/shared/Common/src/lib_scheduler -IC:/workspace/WS/SW/shared/Common/src/lib_sh_mem_netif -IC:/workspace/WS/SW/shared/Common/src/lib_utils -IC:/workspace/WS/SW/shared/Common/src/lib_watchdog -IC:/workspace/WS/SW/Control/submodules/ps -IC:/workspace/WS/SW/Control/submodules/ps/debug -IC:/workspace/WS/SW/Control/submodules/ps/eth_lwip -IC:/workspace/WS/SW/Control/submodules/ps/fifo -IC:/workspace/WS/SW/Control/submodules/ps/utility -IC:/workspace/WS/SW/Control/submodules/shared/drivers -IC:/workspace/WS/SW/Control/submodules/shared/drivers/axi_transfer -IC:/workspace/Models/build/Ctrl/MstrCtlCore_SOKZ -IC:/workspace/Models/build/Ctrl/slprj/sok_zynq/MstrCtlCore -IC:/workspace/Models/build/Ctrl/slprj/sok_zynq/_sharedutils -IC:/workspace/Models/build/Ctrl/slprj/matlab_includes -IC:/workspace/Models/build/integration/code/ctrl -c -fmessage-length=0 -MT"src/SL_MstrCtlCore/slprj/matlab_includes/sfunSum.o" -IC:/workspace/Models/build/_workspace/hw_platform/export/hw_platform/sw/hw_platform/APU_control/bspinclude/include -MMD -MP -MF"src/SL_MstrCtlCore/slprj/matlab_includes/sfunSum.d" -MT"src/SL_MstrCtlCore/slprj/matlab_includes/sfunSum.d" -o "src/SL_MstrCtlCore/slprj/matlab_includes/sfunSum.o" "C:/workspace/Models/build/Ctrl/slprj/matlab_includes/sfunSum.c"
In file included from C:/workspace/Models/build/Ctrl/slprj/matlab_includes/simstruc_compcond.h:462,
from C:/workspace/Models/build/Ctrl/slprj/matlab_includes/simstruc.h:64,
from C:/workspace/Models/build/Ctrl/slprj/matlab_includes/sfunSum.c:35:
C:/workspace/Models/build/Ctrl/slprj/matlab_includes/rt_matrx.h:197:60: error: unknown type name 'mwSize'
197 | extern mxArray *rt_mxCreateNumericArray(int_T ndims, const mwSize *dims,
I'm compiling with '-DRT'. The missing type is defined in tmwtypes.h. What I'm confused about is that this HelpCenter page states that tmwtypes.h will be included with simstruc.h if used as "Coder Product" - which should be the case here. But in simstruc_types.h it looks as if tmwtypes.h will only be included for MATLAB_MEX_FILE:
#if defined(MATLAB_MEX_FILE)
#if !defined(MX_COMPAT_32) && !defined(MX_COMPAT_64) && defined(USE_MEX_CMD)
#if defined(tmwtypes_h)
forceCompilationError tmwtypesbeforesimstrucdetected;
#else
#define MX_COMPAT_32
#endif
#endif
#include "tmwtypes.h"
#else
#include "rtwtypes.h"
#endif
Ho can I pull in the definition of the type?
Best regards
Matthias

채택된 답변

Mark McBroom
Mark McBroom 2024년 2월 17일
편집: Mark McBroom 2024년 2월 17일
You are better off inlining the s-function. If you'd prefer to not write the TLC code required for inlining the C function, you can use the C Function block or the legacy_code tool.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by