Upravit

Sdílet prostřednictvím


struct attribute

The struct keyword is used in a structure type specifier.

struct [[ struct-tag ]] 
{
  [[ [ field-attribute-list ] ]] type-specifier declarator-list;
    ...
};

Parameters

struct-tag

Specifies an optional tag for the structure.

field-attribute-list

Specifies zero or more field attributes that apply to the structure member. Valid field attributes include [first_is], [last_is], [length_is], [max_is], and [size_is]; the usage attributes [string] and [ignore]; the pointer attribute [ref], [unique], or [ptr]; and the union attribute [switch_type]. Separate multiple field attributes with commas.

type-specifier

Specifies a base type, struct, union, or enum type or type identifier. An optional storage specification can precede type-specifier.

declarator-list

Specifies one or more standard C declarators, such as identifiers, pointer declarators, and array declarators. (Function declarators and bit-field declarations are not allowed in structures that are transmitted in remote procedure calls. These declarators are allowed in structures that are not transmitted.) Separate multiple declarators with commas.

Remarks

The IDL structure type specifier, struct, differs from the standard C type specifier in the following ways:

  • Each structure member can be associated with optional field attributes that describe characteristics of that structure member for the purposes of a remote procedure call.
  • Bit fields and function declarators are not allowed in structures that are used in remote procedure calls. These standard C declarator constructs can be used only if the structure is not transmitted on the network.

The shape of structures must be the same across platforms to ensure interconnectivity.

Examples

typedef struct _PITCHER_RECORD_TYPE 
{ 
    short flag; 
    [switch_is(flag)] union PITCHER_STATISTICS_TYPE p; 
} PITCHER_RECORD_TYPE;

See also

arrays

Arrays and Pointers

Array and Sized-Pointer Attributes

MIDL Base Types

/c_ext

context_handle

enum

first_is

Interface Definition (IDL) File

ignore

last_is

length_is

max_is

/osf

ptr

ref

size_is

string

switch_type

union

unique