Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
COM
id
in
int
odl
out
ptr
ref
Expand Minimize

range attribute

The [range] attribute lets you specify a range of allowable values for arguments or fields whose values are set at run time. When used with a pipe type, the attribute specifies the allowable range for the count of elements in the pipe chunks.


[range(low-val,high-val)] type-specifier declarator

Parameters

low-val

The lowest allowable value that the parameter or field can hold.

high-val

The highest allowable value that the parameter or field can hold.

type-specifier

An integral type other than hyper or __int64, a type identifier to an integral type, an enum type, or a pipe type name.

declarator

A standard C declarator, such as an identifier.

Remarks

Use the [range] attribute to modify the meaning of sensitive parameters or fields, such as those used for size or length, with conformant or varying arrays; or whenever you want to check a parameter or field value against a range of valid values. The attribute is applicable to top-level parameters as well as lower-level parameters and fields. Adding the [range] attribute to a type does not change its wire format, thus does not affect backward compatibility.

The [range] attribute can also be used on conformant data such as buffers or arrays with a conformance attribute. The effect is to limit all conformance sizes for the conformant data to the specified range. If the conformant data is a multi-dimensional array, each array dimension is limited to the specified range.

Use of [range] on conformant data requires that the compilation target be –target NT60 or higher.

Note that you must use the /robust compiler option when you compile your IDL file in order to generate the stub code that will perform these checks. Without the /robust switch, the MIDL compiler ignores this attribute.

Examples

HRESULT Method1(
    [in, range(0,100)] ULONG m,
    [in, range(0,100)] ULONG n,
    [size_is(m,n)] ULONG **pplong);

void InPipe(
    [in, range(0, MAX_CHUNK) LONG_PIPE pipe_date);

See also

Interface Definition (IDL) File
arrays
first_is
last_is
length_is
max_is
/robust
size_is
switch_is

 

 

Community Additions

ADD
Show:
© 2015 Microsoft