optional

return-type func-name([optional [, other-attributes]param-type param-name)

Example

HRESULT MyFunc([in, optional] VARIANT Param1, 
               [out, optional] VARIANT Param2)
 

Remarks

The optional attribute specifies an optional parameter for a member function. This attribute is valid only if the parameter is of type VARIANT or VARIANT*.

The MIDL compiler accepts the following parameter ordering (from left-to-right):

  1. Required parameters (parameters that do not have the defaultvalue or optional attributes),
  2. optional parameters with or without the defaultvalue attribute,
  3. parameters with the optional attribute and without the defaultvalue attribute,
  4. lcid parameter, if any,
  5. retval parameter

You cannot apply the optional attribute to a parameter that also has the lcid or retval attributes.

See Also

ODL File Syntax, ODL File Example, Generating a Type Library With MIDL, Differences Between MIDL and MKTYPLIB