Keywords: doc

Next: Compiler and Linker Wrappers Up: Implementation Overview Previous: Using a Servant Manager

# IDL Compiler

MICO offers its own IDL-compiler called `idl` which is briefly described in this section. The tool is used for translating IDL-specifications to C++ as well as feeding IDL-specifications into the interface repository. The `idl` tool takes its input either from a file or an interface repository and generates code for C++ or CORBA-IDL. If the input is taken from a file, the `idl` tool can additionally feed the specification into the interface repository. The synopsis for `idl` is as follows:

      idl [--help] [--version] [-D<define>] [-I<path>] \
          [--no-exceptions] [--codegen-c++] [--no-codegen-c++] \
          [--codegen-c++] [--no-codegen-c++] [--codegen-idl] \
          [--no-codegen-idl] [--c++-suffix=<suffix>] [--c++-impl] \
          [--h-suffix=<suffix>] [--absolute-paths] [--emit-repoids] \
          [--query-server-for-narrow] [--feed-ir] [--feed-included-defs] \
          [--repo-id=<id>] [--name=<prefix>] [--pseudo] \
          [--poa] [--no-poa] [--boa] [--no-boa] [--no-poa-ties] [<file>]

In the following a detailed description of all the options is given:

`-help`
  Gives an overview of all supported command line options.
`-version`
  Prints the version of MICO.
`-D<define>`
  Defines a preprocessor macro. This option is equivalent to the `-D` switch of most C-compilers.
`-I<path>`
  Defines a search path for `#include` directives. This option is equivalent to the `-I` switch of most C-compilers.
`-no-exceptions`
  Tells `idl` to disable exception handling in the generated code. Code for the exception classes is still generated but throwing exceptions will result in an error message and abort the program. This option can only be used in conjunction with `-codegen-c++`. This option is off by default.
`-codegen-c++`
  Tells `idl` to generate code for C++ as defined by the language mapping IDL to C++. The `idl` tool will generate two files, one ending in `.h` and one in `.cc` with the same basenames. This option is the default.
`-no-codegen-c++`
  Turns off the code generation for C++.
`-codegen-c`
  Tells `idl` to generate code for C as defined by the language mapping IDL to C. The `idl` tool will generate three files, ending in `-skel.cc`, `-stub.cc` and `-c.h` with the same basenames.
`-no-codegen-c`
  Turns off the code generation for C. This is the default.
`-codegen-idl`
  Turns on the code generation for CORBA-IDL. The `idl` tool will generate a file which contains the IDL specification which can again be fed into the `idl` tool. The basename of the file is specified with the `-name` option.
`-no-codegen-idl`
  Turns off the code generation of CORBA-IDL. This option is the default.
`-c++-suffix=<suffix>`
  If `-codegen-c++` is selected, then this option determines the suffix for the C++ implementation file. The default is ```cc`''.
`-c++-impl`
  This option will cause the generation of some default C++ implementation classes for all interfaces contained in the IDL specification. This option requires `-codegen-c++`.
`-hh-suffix=<suffix>`
  If `-codegen-c++` is selected, then this option determines the suffix for the C++ header file. The default is ```h`''.
`-h-suffix=<suffix>`
  If `-codegen-c` is selected, then this option determines the suffix for the C header file. The default is ```h`''.
`-relative-paths`
  If selected, included files (via the `#include` directive) will be referenced in a relative way (i.e. `#include <...>`).
`-emit-repoids`
  This option will cause `#pragma` directives to be emitted, which associate the repository id of each IDL construct. This option can only be used in conjunction with the option `-codegen-idl`.
`-query-server-for-narrow`
  This option can only be used in conjunction with the `-codegen-c++` switch. If it is used, the IDL compiler will insert special code for all `_narrow()` methods for querying the server at runtime. See `test/idl/26/README` for further comments.
`-feed-ir`
  The CORBA-IDL which is specified as a command line option is fed into the interface repository. This option requires the `ird` daemon to be running.
`-feed-included-defs`
  This option can only be used in conjunction with `-feed-ir`. If this option is used, IDL definitions located in included files are fed into the interface repository as well. The default is to feed only the definitions of the main IDL file into the IR.
`-repo-id=<id>`
  The code generation is done from the information contained in the interface repository instead from a file. This option requires the `ird` daemon to be running. The parameter `id` is a repository identifier and must denote a CORBA module.
`-name=<prefix>`
  This option controls the prefix of the file names if a code generation is selected. This option is mandatory if the input is taken from the interface repository. If the input is taken from a file, the prefix is derived from the basename of the file name.
`-pseudo`
  Generates code for ``pseudo interfaces''. No stubs, skeletons or code for marshalling data to and from ``any'' variables is produced. Only supported for C++ code generation.
`-poa`
  Turns on generation of skeleton classes based on the Portable Object Adapter (POA).
`-no-poa`
  Turns off generation of POA-based skeletons. This is the default.
`-no-poa-ties`
  When using `-poa`, this option can be used to turn off generation of Tie classes if not needed.
`-boa`
  Turns on generation of skeleton classes using the Basic Object Adapter (BOA). This is the default.
`-no-boa`
  Turns off generation of BOA-based skeletons.

Here are some examples on how to use the `idl` tool:

`idl account.idl`
  Translates the IDL-specification contained in account.idl according to the C++ language mapping. This will generate two files in the current directory.
`idl -feed-ir account.idl`
  Same as above but the IDL-specification is also fed into the interface repository.
`idl -feed-ir -no-codegen-c++ account.idl`
  Same as above but the generation of C++ stubs and skeletons is omitted.
`idl -repo-id=IDL:Account:1.0 -no-codegen-c++ -codegen-idl -name=out`
  This command will generate IDL-code from the information contained in the interface repository. This requires the `ird` daemon to be running. The output is written to a file called `out.idl`.
`idl -no-codegen-c++ -codegen-idl -name=out account.idl`
  This command will translate the IDL-specification contained in `account.idl` and into a semantical equivalent IDL-specification in file `out.idl`. This could be useful if you want to misuse the IDL-compiler as a pretty printer.

Next: Compiler and Linker Wrappers Up: Implementation Overview Previous: Using a Servant Manager