MATLAB Link for Code Composer Studio Development Tools | ![]() ![]() |
Return an object that accesses one member of a structure
Syntax
Description
objname2 = getmember(objname,membername)
returns the object objname2
that represents membername
, a member of the structure that objname
accesses. membername
must be a string and objname
must represent a structure in memory. Once you create objname2
, it becomes the object you use to read and write membername
. Along with createobj
, these are the only functions that create objects in the product.
The class of objname2
depends on the data type of membername
--numeric structure members return numeric objects, enumerated members return enum objects, pointers return pointer objects, and so on.
objname2 = getmember(objname,index,membername)
Examples
Suppose you have declared a structure in your source code called testdeepstr, using code like this:
Now, getmember
creates objects that directly access members of str_recur
.
str_recur=createobj(cc,'str_recur') STRUCTURE Object: Symbol Name : str_recur Address : [ 2147500816 0] Address Units per value : 224 AU Size : [ 1 ] Total Address Units : 224 AU Array ordering : row-major Members : 'x_int', 'x_str', 'z_str' x_str=getmember(structtest,'x_str') STRUCTURE Object: Symbol Name : x_str Address : [ 2147500824 0] Address Units per value : 72 AU Size : [ 1 ] Total Address Units : 72 AU Array ordering : row-major Members : 's_int', 'a_int', 's_double', 'a_char'
Even when the structure member is itself a structure, getmember
provides access directly to the nested structure, or indeed to members within the nested structure.
s_double=getmember(nestx_str,'s_double') NUMERIC Object Symbol Name : s_double Address : [ 2147500872 0] Wordsize : 64 bits Address Units per value : 8 AU Representation : float Binary point position : 0 Size : [ 1 ] Total address units : 8 AU Array ordering : row-major Endianness : little
Numeric object s_int
is now your handle to write to or read from member s_double
.
See Also
![]() | get | goto | ![]() |