xHarbour Reference Documentation > Statement Reference |
Creates a new structure object
<var> := (struct <StructureName>) or <var> := (struct <StructureName>*) <pointer>
The (struct) statement provides the most convenient way of creating a structure object of a declared C structure. (struct) is not a statement in its strongest definition, since it is used on the right side of the assignment operator and produces a return value: a new C Structure object. The name of a declared structure <StructureName> must be provided with the (struct) statement. A corresponding structure object is then instantiated and assigned to the memory variable <var>. This structure object maintains an uninitialized C structure.
When the (struct) statement is coded with an asterisk, an additional memory variable <pointer> must follow the closing brace. This variable must be of Valtype()=="P", i.e. it is a pointer holding the memory address of structure data. The created structure object is then initialized with the structure data stored at the memory address of <pointer>. This is required in the special case when an external function called via DllCall() produces a pointer to a new structure. Data pointed to by <pointer> is then transferred into a new xHarbour structure object.
Note: refer to the typedef struct statement for a usage example of (struct).
See also: | C Structure class, DllCall(), pragma pack(), typedef struct |
Category: | C Structure support , xHarbour extensions |
Header: | cstruct.ch, winapi.ch, wintypes.ch |
Source: | rtl\cstruct.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
http://www.xHarbour.com