PreviousNext

The code and nocode Attributes

The code and nocode attributes allow you to control which operations in the IDL file have client stub code generated for them by the compiler. These attributes affect only the generation of a client stub; they have no effect when generating the server stub.

The code and nocode attributes have the following syntax. (See the example at the end of this topic.)

For an interface:

[code | nocode] interface interface_name

For an operation:

[code | nocode ] operation_name ([parameter_list]);

When you specify nocode as an attribute on an ACF interface, stub code is not generated for the operations in the corresponding IDL interface unless you also specify code for the particular operation(s) for which you want stub code generated. Similarly, when you specify code (the default) as an attribute on an ACF interface, stub code is generated for the operations in the corresponding IDL interface unless you also specify nocode for the particular operations for which you do not want stub code generated.

Do not use nocode on any of the operations if the compiler is generating only server stub code because it has no effect. Server stubs must always contain generated code for all operations.

In the following example, the IDL compiler generates client stub code for the operations open, read, and close, but not for the operation write. An alternative method for specifying the same behavior is to use [nocode] write ( ) in the ACF.

Example Using the code and nocode Attributes

ACF

[nocode,auto_handle] interface open_read_close

{

[code] open();

[code] read();

[code] close();

}

IDL File

[uuid(2166d580-0c69-11ca-811d-08002b111685)]

interface open_read_close

{

void open (...);

void read (...);

void write (...);

void close (...);

}