C struct import problem with Matlab/Simulink R2021b if struct contains an array with one element

2 ビュー (過去 30 日間)
if a struct definition contains a member array with one element Matlab function Simulink.importExternalCTypes() issues a warning
'Warning: Unable to import 'MyStruct' from file 'D:\MathworksExample\structdef.h'. It is empty or
has a field whose type is unsupported in Simulink.'
This works in R2018b without any problem.
In R2021b dimension of array must be greater than one to successfully import struct definition.
example struct
// file structdef.h
#include <stdint.h>
typedef struct
{
int32_t itemId;
uint8_t check[1]; // fails with one element, ok with dimension 2 or more
} MyStruct;
import with Simulink.importExternalCTypes('structdef.h') gives a warning;
Warning: Unable to import 'MyStruct' from file 'D:\MathworksExample\structdef.h'. It is empty or has a field
whose type is unsupported in Simulink.
  2 件のコメント
JulianSTABL
JulianSTABL 2022 年 3 月 23 日
I have the exact same problem, did you find out in the meanwhile how to workaround this?
Thomas Klingelhöfer
Thomas Klingelhöfer 2022 年 3 月 23 日
There is no solution known to me at this time but related to this topic there is an ongoing case opened at MathWorks.

サインインしてコメントする。

採用された回答

Sanju
Sanju 2024 年 2 月 15 日
I have tried to import the file with single & Multi Dimensions in MATLAB R2023b, and it’s working fine.
Also, in MATLAB R2022a and earlier versions, the use of N-dimensional arrays within structs was not supported, hence the warning is an anticipated behaviour. Starting from R2022b, importing multidimensional arrays is supported.
So, it is recommended to upgrade to MATLAB R2022b or a newer release to utilize the latest functionality.
Please refer to the below documentation links if required,
Hope this Helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by