length_is

[length_is( limited-expression-list )]

limited-expression-list

Specifies one or more C-language expressions. Each expression evaluates to an integer that represents the number of array elements to be transmitted. 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

/* counted string holding at most "size" characters */

typedef struct { 

     unsigned short size;

     unsigned short length;

     [size_is(size), length_is(length)] char string[*];

 } COUNTED_STRING_TYPE;

 

/* counted string holding at most 80 characters */

typedef struct { 

     unsigned short length;

     [length_is(length)] char string[80];

 } STATIC_COUNTED_STRING_TYPE;

 

void Proc1(

    [in] short iLength;

    [in, length_is(iLength)] short asNumbers[10];

 

Remarks

The length_is attribute specifies the number of array elements to be transmitted. A non-negative value must be specified.

The length_is attribute determines the value of the array indexes corresponding to the last_is attribute when last_is is not specified. The relationship between these array indexes is as follows:

length = last - first + 1

 

The length_is attribute cannot be used at the same time as the last_is attribute or the string attribute.

To define a counted string with a length_is or last_is attribute, use a character array or pointer without the string attribute.

Using a constant expression with the length_is attribute is an inappropriate use of the attribute. It is legal, but inefficient, and will result in slower marshalling code.

See Also

field_attributes, first_is, IDL, last_is, max_is, min_is, size_is