PreviousNext

The include Statement and the C++ cstub and sstub

The include statement specifies any additional header files you want included in the generated stub code. You can specify more than one header file. The include statement is placed in the body of the ACF and has the following syntax:

include "filename" [,"filename"] …;

[ [sstub | cstub | sstub, cstub]] include "filename";

Do not specify the directory name or file extension when you use the include statement. The compiler appends the .h extension. If you want to specify the directory name(s), use the -cc_opt or -I IDL compiler command options.

Use the include statement whenever you use the represent_as, implicit_handle, cs_char, cxx_static, cxx_new, cxx_lookup, or cxx_delegate attributes and the specified type is not defined or imported in the IDL file.

The sstub and cstub attributes are optional. By default, the IDL compiler places directives only in the idl-generated header file when neither the sstub nor cstub attributes are used. These attributes restrict where #include compiler directives are placed in order to include application-specific header files in C++ client and server stub files. In C++ applications, local and remote versions of operations are included together by linking in both the client and server stubs. C++ applications need to control #include compiler directives so that the operations for local objects can be easily renamed to avoid name conflicts with the operations for remote objects.

The following table shows to which output file the IDL compiler places the #include compiler directive for the application-specific file. Note that the idl-generated header file is always included automatically in each stub.

ACF Statement Header File Client Stub Server Stub
include "file"; X
[cstub] include "file"; X
[sstub] include "file"; X
[cstub, sstub] include "file"; X X