Compiler error indicates a type is redefined. Simulink model won't run in external mode on my machine due to tmwtypes.h rtwtypes.h error?

32 visualizaciones (últimos 30 días)
Hi, I am currently trying to run a Simulink model in external mode to run on an Arduino Mega2560. I have successfully ran it on a University computer but now receiving the error below on my personal machine. The model contains a custom S-Function block receiving sensor data connected to a controller and Arduino inputs.
I am assuming the issue is related to the program files on my machine as the rtwtypes.h file is automatically produced into my working directory when trying to run.
"#Include "tmwtypes.h" is already included in the s-function wrapper code.
I've looked through the documentation suggested and can't find what I might need to do or what I might have changed to get this error.
In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_utils.h:7:0, from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:61: C:/PROGRA~1/MATLAB/R2016a/extern/include/tmwtypes.h:498:17: error: conflicting types for 'real_T' typedef REAL_T real_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:48:0: C:/Users/USER/Dropbox/3RDYEA~1/Matlab/MPU6050/FRESHT~1/XSBR_Model_ert_rtw/rtwtypes.h:64:16: note: previous declaration of 'real_T' was here typedef double real_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_utils.h:7:0, from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:61: C:/PROGRA~1/MATLAB/R2016a/extern/include/tmwtypes.h:507:17: error: conflicting types for 'time_T' typedef TIME_T time_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:48:0: C:/Users/USER/Dropbox/3RDYEA~1/Matlab/MPU6050/FRESHT~1/XSBR_Model_ert_rtw/rtwtypes.h:65:16: note: previous declaration of 'time_T' was here typedef double time_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_utils.h:7:0, from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:61: C:/PROGRA~1/MATLAB/R2016a/extern/include/tmwtypes.h:543:16: error: conflicting types for 'byte_T' typedef BYTE_T byte_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:48:0: C:/Users/USER/Dropbox/3RDYEA~1/Matlab/MPU6050/FRESHT~1/XSBR_Model_ert_rtw/rtwtypes.h:72:16: note: previous declaration of 'byte_T' was here typedef char_T byte_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_utils.h:7:0, from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:61: C:/PROGRA~1/MATLAB/R2016a/extern/include/tmwtypes.h:555:7: error: conflicting types for 'creal32_T' } creal32_T; ^ In file included from C:/PROGRA~1/MATLAB/R2016a/rtw/c/src/ext_mode/serial/rtiostream_serial_interface.c:48:0: C:/Users/USER/Dropbox/3RDYEA~1/Matlab/MPU6050/FRESHT~1/XSBR_Model_ert_rtw/rtwtypes.h:82:3: note: previous declaration of 'creal32_T' was here } creal32_T; ^ gmake: * [rtiostream_serial_interface.o] Error 1 ### Creating HTML report file XSBR_Model_codegen_rpt.html ### Build procedure for model: 'XSBR_Model' aborted due to an error. Error(s) encountered while building "XSBR_Model": ### Failed to generate all binary outputs.
The compiler error indicates that a type is redefined. This error can occur if your custom code includes the header file tmwtypes.h instead of rtwtypes.h. For information about using the directive #include "tmwtypes.h" in custom code, refer to the documentation. Alternatively, specify backwards compatibility for your model by running set_param('XSBR_Model', 'InferredTypesCompatibility', 'on').
  5 comentarios

Iniciar sesión para comentar.

Respuestas (1)

Liming Gao
Liming Gao el 22 de Mayo de 2022
You may replace the code "#include "rtwtypes.h" " in *.h files with
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
ref: https://www.mathworks.com/help/rtw/ug/build-process-files.html#f1159207

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by