Export (0) Print
Expand All
COM
id
in
int
odl
out
ptr
ref
Expand Minimize

max_is attribute

The [max_is] attribute designates the maximum value for a valid array index.


[max_is(limited-expression-list )]

Parameters

limited-expression-list

Specifies one or more C-language expressions. Each expression evaluates to an integer that represents the highest valid array index. The MIDL compiler supports conditional expressions, logical expressions, relational expressions, and arithmetic expressions. MIDL does not allow function invocations in expressions and does not allow increment and decrement operators. Separate multiple expressions with commas.

Remarks

The [max_is] attribute does not necessarily correspond to the number of elements in the array. For an array of size n in C, where the first array element is element number zero, the maximum value for a valid array index is n–1.

The [max_is] attribute cannot be used as a field attribute at the same time as the [size_is] attribute.

While it is legal to use the [max_is] attribute with a constant expression, doing so is inefficient and unnecessary. For example, use a fixed size array:

/* transmits values of a[0]... a[MAX_SIZE-1] */ 
HRESULT Proc3([in] short Arr[MAX_SIZE]); 

instead of:

/* legal but marshaling code is much slower */ 
HRESULT Proc3([in max_is(MAX_SIZE-1)] short Arr[] );

Examples

/* if m = 10, there are 11 transmitted elements (a[0]...a[10])*/ 
HRESULT Proc1( 
    [in] short m, 
    [in, max_is(m)] short a[]);  
 
/* if m = 10, the valid range for b is b[0...10][20] */ 
HRESULT Proc2( 
    [in] short m, 
    [in, max_is(m)] short b[][20];

See also

Field Attributes
Interface Definition (IDL) File
min_is
size_is

 

 

Community Additions

ADD
Show:
© 2014 Microsoft