Skip to main content
Skip table of contents

Using the Slice Compiler

Common Options

Ice provides a Slice compiler for each language mapping. The compilers share a similar command-line syntax:

BASH
slice2<name> [options] file...

Regardless of which compiler you use, a number of command-line options are common to the compilers for any language mapping:

  • -h, --help
    Displays a help message.

  • -v, --version
    Displays the compiler version.

  • -DNAME
    Defines the preprocessor symbol NAME.

  • -DNAME=DEF
    Defines the preprocessor symbol NAME with the value DEF.
    Each compiler always predefines the __<compiler name in upper case>__ macro when compiling Slice file. For example, slice2cpp predefines __SLICE2CPP__.

  • -UNAME
    Undefines the preprocessor symbol NAME.

  • -IDIR
    Add the directory DIR to the search path for #include directives.

  • --output-dir DIR
    Place the generated files into directory DIR, which must already exist.

  • -d, --debug
    Print debug information showing the operation of the Slice parser.

  • --depend
    Print dependency information in Makefile format to standard output by default, or to the file specified by the --depend-file option.

  • --depend-xml
    Print dependency information in XML format to standard output by default, or to the file specified by the --depend-file option.

  • --depend-file FILE
    Directs dependency information to the specified file. The output format depends on whether --depend,  --depend-xml, or --depend-json is specified.

  • --validate
    Checks the provided command-line options for correctness, and does not generate any code.

The Slice compilers permit you to compile more than a single source file, so you can compile several Slice definitions at once, for example:

BASH
slice2cpp -I. file1.ice file2.ice file3.ice

The Slice Compiler for PHP

The Slice-to-PHP compiler (slice2php) offers one additional option:

  • --all
    Generate code for all Slice definitions, including those from included files.

Compiler Output

For each Slice file X.iceslice2php generates PHP code into a file named X.php in the output directory. The default output directory is the current working directory, but a different directory can be specified using the --output-dir option.

Include Files

It is important to understand how slice2php handles include files. In the absence of the --all option, the compiler does not generate PHP code for Slice definitions in included files. Rather, the compiler translates Slice #include statements into PHP require statements in the following manner:

  1. Determine the full pathname of the included file.

  2. Create the shortest possible relative pathname for the included file by iterating over each of the include directories (specified using the -I option) and removing the leading directory from the included file if possible.
    For example, if the full pathname of an included file is /opt/App/slice/OS/Process.ice, and we specified the options -I/opt/App and -I/opt/App/slice, then the shortest relative pathname is OS/Process.ice after removing /opt/App/slice.

  3. Replace the .ice extension with .php. Continuing our example from the previous step, the translated require statement becomes

    CODE
    require_once "OS/Process.php";

    As a result, you can use -I options to tailor the require statements generated by the compiler in order to avoid absolute path names and match the organizational structure of your application's source files. 

See Also
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.