Buses as inputs/outputs in C MEX S-Functions and vectors as structure members
1 view (last 30 days)
Show older comments
Hi everybody,
I need help, I've already learned how to define buses as outputs/inputs of a c-mex functions with the legacy code tool but what I need now is that my structures which are actually the buses have vectors as members. Something like :
typedef struct sTestData {
std::vector<Type_A> member1;
std::vector<Type_B> member2;
} TestData_t;
when I try to generate the code for the c-mex function and compile it I receive several errors :
error C2039: '..': is not a member of 'std::vector<_Ty>' with [ _Ty=Type_A ]
I hope someone can help me.
0 Comments
Answers (1)
Kaustubha Govind
on 24 Aug 2012
First, std::vector is a C++ data structure, so you can't use them inside C S-functions, you'll need to use C++ S-functions. Second, Simulink does not support dynamic allocation, so data structures like std::vectors are not allowed. You might need to convert your std::vectors to built-in arrays (which is fairly easy using an intermediate type and extracting the built-in array under the std::vector using &member1[0]) of fixed-size (or of a fixed maximum size at any rate if you plan to create a bus containing variable-size signals).
2 Comments
Kaustubha Govind
on 27 Aug 2012
What are Type_A and Type_B typedef'd to? Is the type declaration in the same header?
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!