max_is

[max_is(limited-expression-list )]

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.

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];
 

Remarks

The max_is attribute designates the maximum value for a valid array index. 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 marshalling code is much slower */ 
HRESULT Proc3([in max_is(MAX_SIZE-1)] short Arr[] ); 
 

See Also

field_attributes, IDL, min_is, size_is