Issue with Importing Custom Code in Simulink after Migrating Project from Windows to macOS

54 visualizzazioni (ultimi 30 giorni)
I recently migrated a Simulink project from my Windows machine to macOS (using MATLAB R2024b). However, when attempting to import custom C code, I encountered several errors. Here are the main parts of the error message:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
MEX 已成功完成。
使用 'Xcode with Clang' 编译。
/Volumes/ITGZ_RC20/SimCache/slprj/_sfprj/C_CCS1/_self/sfun/src/c1_C_CCS1.c:116:25: warning: incompatible pointer types passing 'const uint32_T *' (aka 'const unsigned long *') to parameter of type 'const unsigned int *' [-Wincompatible-pointer-types]
116 | 0U, &c1_decisionTxtStartIdx, &c1_decisionTxtEndIdx);
| ^~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/extern/include/covrt.h:426:70: note: passing argument to parameter 'decStartInd' here
426 | const unsigned int* decStartInd,
| ^
/Volumes/ITGZ_RC20/SimCache/slprj/_sfprj/C_CCS1/_self/sfun/src/c1_C_CCS1.c:116:50: warning: incompatible pointer types passing 'const uint32_T *' (aka 'const unsigned long *') to parameter of type 'const unsigned int *' [-Wincompatible-pointer-types]
116 | 0U, &c1_decisionTxtStartIdx, &c1_decisionTxtEndIdx);
| ^~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/extern/include/covrt.h:427:70: note: passing argument to parameter 'decEndInd' here
427 | const unsigned int* decEndInd);
| ^
/Volumes/ITGZ_RC20/SimCache/slprj/_sfprj/C_CCS1/_self/sfun/src/c1_C_CCS1.c:220:44: warning: incompatible pointer types passing 'c1_Mdata *' (aka 'struct c1_tag_s8LjUYZjUdK3gtXdOIx2PrB *') to parameter of type 'Mdata *' [-Wincompatible-pointer-types]
220 | MC_Invocation_5KzdHlGKVIF8dHD4YqHZsF(&c1_DTFC_h, &c1_epwm_h);
| ^~~~~~~~~~
/Volumes/ITGZ_RC20/SimCache/slprj/_slcc/5KzdHlGKVIF8dHD4YqHZsF/slcc_interface_5KzdHlGKVIF8dHD4YqHZsF.h:601:71: note: passing argument to parameter 'handle' here
601 | DLL_EXPORT_CC extern void MC_Invocation_5KzdHlGKVIF8dHD4YqHZsF(Mdata *handle, EPWMdata *epwmd);
| ^
/Volumes/ITGZ_RC20/SimCache/slprj/_sfprj/C_CCS1/_self/sfun/src/c1_C_CCS1.c:220:56: warning: incompatible pointer types passing 'c1_EPWMdata *' (aka 'struct c1_tag_s7YJuIOKub7qJWwst9F9PDB *') to parameter of type 'EPWMdata *' [-Wincompatible-pointer-types]
220 | MC_Invocation_5KzdHlGKVIF8dHD4YqHZsF(&c1_DTFC_h, &c1_epwm_h);
| ^~~~~~~~~~
/Volumes/ITGZ_RC20/SimCache/slprj/_slcc/5KzdHlGKVIF8dHD4YqHZsF/slcc_interface_5KzdHlGKVIF8dHD4YqHZsF.h:601:89: note: passing argument to parameter 'epwmd' here
601 | DLL_EXPORT_CC extern void MC_Invocation_5KzdHlGKVIF8dHD4YqHZsF(Mdata *handle, EPWMdata *epwmd);
| ^
4 warnings generated.
MEX 已成功完成。
In file included from /Volumes/ITGZ_RC20/SimCache/slprj/_sfprj/C_CCS1/_self/sfun/src/C_CCS1_sfun_registry.c:255:
In file included from /Applications/MATLAB_R2024b.app/simulink/include/sf_runtime/stateflow_mdl_methods.stub:258:
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3931:9: error: 'uint32_T *' (aka 'unsigned long *') and 'uint_T *' (aka 'unsigned int *') are not pointers to compatible types
3931 | SETU(ssGetChecksum0);
| ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3917:45: note: expanded from macro 'SETU'
3917 | i = (int_T)((uint_T)((&sizefield(S) - (uint_T*)ssGetSizesPtr(S)))); \
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3932:9: error: 'uint32_T *' (aka 'unsigned long *') and 'uint_T *' (aka 'unsigned int *') are not pointers to compatible types
3932 | SETU(ssGetChecksum1);
| ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3917:45: note: expanded from macro 'SETU'
3917 | i = (int_T)((uint_T)((&sizefield(S) - (uint_T*)ssGetSizesPtr(S)))); \
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3933:9: error: 'uint32_T *' (aka 'unsigned long *') and 'uint_T *' (aka 'unsigned int *') are not pointers to compatible types
3933 | SETU(ssGetChecksum2);
| ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3917:45: note: expanded from macro 'SETU'
3917 | i = (int_T)((uint_T)((&sizefield(S) - (uint_T*)ssGetSizesPtr(S)))); \
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3934:9: error: 'uint32_T *' (aka 'unsigned long *') and 'uint_T *' (aka 'unsigned int *') are not pointers to compatible types
3934 | SETU(ssGetChecksum3);
| ^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3917:45: note: expanded from macro 'SETU'
3917 | i = (int_T)((uint_T)((&sizefield(S) - (uint_T*)ssGetSizesPtr(S)))); \
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3935:9: error: 'uint32_T *' (aka 'unsigned long *') and 'uint_T *' (aka 'unsigned int *') are not pointers to compatible types
3935 | SETU(ssGetOptions);
| ^~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2024b.app/simulink/include/simulink.c:3917:45: note: expanded from macro 'SETU'
3917 | i = (int_T)((uint_T)((&sizefield(S) - (uint_T*)ssGetSizesPtr(S)))); \
| ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.
MEX 已成功完成。
gmake: *** [C_CCS1_sfun_registry.o] Error 255
gmake: *** Waiting for unfinished jobs....
-------------------------------------------------------------------------------------------------------------------------------------------------
I suspect that this issue might be related to either the way the code is set up or potential compatibility problems with macOS. The error messages indicate warnings about incompatible pointer types and other related issues.
Has anyone experienced similar problems when migrating projects between platforms? Could this be due to the code import process, or is it more likely to be a compatibility issue with the macOS environment?

Risposte (1)

Divyanshu
Divyanshu il 26 Nov 2024 alle 6:05
Modificato: Divyanshu il 26 Nov 2024 alle 6:23
Most probably it is a compatibility issue because earlier the project was configured in windows. Also, the custom c code would have been compiled using default compiler configured for mex command in windows.
But now in macOS the default compiler configured for macOS would be used by mex, hence it is throwing errors.
Maybe you can try to change the default compilers and make them compatible across both platforms. You can refer Change Default Compiler.
Hope it helps!

Categorie

Scopri di più su Dependency Analysis in Help Center e File Exchange

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by