---
name: "opencxx"
section: "1"
platform: "linux"
package: "openc++"
version: "2.5.3-3"
release: "Debian 2.1 (Slink)"
platforms: ["linux"]
url: "https://new.carta.tech/occ"
---

# opencxx(1)

"Open C++ compiler"

Part of [occ(1)](/occ/1.md).

## NAME

occ - "Open C++ compiler"

## SYNOPSIS

**occ** \[ **-l** \] \[ **-s** \] \[ **-V** \] \[ **-v** \]\
\
     \[ **-m  *file\_name***  \] \[ **-c** \] \[ **-E** \] \[ **-n** \] \[ **-p** \]\
\
     \[ **--regular-c++** \] \[ **-I  *include\_directory*** \]\
\
     \[ **-D  *name*** \[ =  *def* \] \]\
\
     \[ **-M  *option*** \[=  *value*\]\]\
\
     \[ **---  *C++ compiler options***  \[  *.o and .a files*\]\] \
       *source\_file*

## DESCRIPTION

**occ** compiles an OpenC++ program into an object file. It first invokes the C++ preprocessor with the predefined macro  **opencxx**   and generates a  **.occ**   file, then translates it into a  **.ii**   file according to the meta-level program. The   **.ii**   file is compiled by the back-end C++ compiler, and finally an   **a.out**   file is produced.  If   **occ**   is run with the   **-c**   option, it generates a   **.o**   file but suppresses linking.

For example, to compile a base-level program   **sample.cc**   with the meta-level program   **MyClass.mc**  , the user should do as follows:

% occ -m MyClass.mc

First,   **MyClass.mc**   should be compiled into shared  libraries  **MyClass.so**   and   **MyClass-init.so**  . The produced shared libraries must be under the directory specified by   **LD\_LIBRARY\_PATH**  . Then, the user can compile the base-level program:

% occ -- -o sample sample.cc

If   **sample.cc**   requires a metaclass   **MyClass**  ,   **occ**   dynamically loads and links   **MyClass.so**   and   **MyClass-init.so**  . Then   **sample.cc**   is compiled according to the metaclass   **MyClass**    and an executable file   **sample**   is produced.

The separate compilation of meta-level programs is also supported. Suppose that   **MyClass**   is implemented by   **foo.mc**   and   **bar.mc** . The user should compile them as follows:

% occ -c -m foo.mc\
 % occ -c -m bar.mc

This produces   **foo.o**  ,   **bar.o**  , and   **MyClass-init.so**  . Although the second invocation of   **occ**   overrides  **MyClass-init.so**  produced by the first invocation, this is not a problem.  To get the shared library,  **foo.o**  and   **bar.o**   have to be linked by hand into   **MyClass.so**   by:

% occ -mMyClass foo.o bar.o

meta-level program with the OpenC++ compiler.  To do this, the user must not specify the   **-m**   option:

% occ -- -o myocc opencxx.a MyClass.mc

First,   **MyClass.mc**   should be compiled and linked to the OpenC++ compiler.  The command shown above produces the OpenC++ compiler that  **MyClass.mc**   is embedded in.    **opencxx.a**   is the archive of the original OpenC++ compiler.  (Note: The Solaris and Linux users have to add the   **-ldl**   option after   **opencxx.a**  .)

Then, the produced compiler   **myocc**   is used to compile the base-level program:

% myocc -- -o sample sample.cc

This compiles   **sample.cc**   and produces an executable file   **sample**  .

## OPTIONS

**-D** Define a macro  **name**   as   **def**  .

**-E** Don't run the back-end C++ compiler.  Stop after generating a   **.ii**   file.

**-I** Add a    **directory**    to the search path of the **#include directive.**

**-M** Specify an    **option**    with    **value**   .  It is passed to metaobjects.

**-V** Show the version number.

**-c** Suppress linking and produce a   **.o**   file.

**-l** Print the list of statically loaded metaclasses.

**-m** Produce a shared library (a   **.so**   file.)  This is used to compile a metaclass. If    **file\_name**    is specified, the name of the shared library is   **file\_name .so**  . If the .B   **-c**    option is specified together,  **occ**  produces a   **.so**   file, which should be linked by the user to be a shared library.

**-n** Suppress invoking the preprocessor.

**-p** Stop after the parsing stage.  No translation is done.

**-s** Print the whole parse tree of the given source program.\
 	Don't perform translation or compilation.  If no source file is\
 	given,   **occ**   reads from the standard input.

**-v** Specify the verbose mode.

**--regular-c++** Inhibit the extended syntax.  This enables the keyword   **metaclass**   to be used as a variable name. This option is useful when parsing legacy code being not intended to translation.  When this option is used, the symbol   **\_\_opencxx**   is not defined.

**--** The following options are interpreted as options for the back-end C++ compiler. For example, if you type

% occ -I.. -- -g foo.c

Then the .B   **-g**    option is passed to the C++ compiler. Note that these options are not passed to the C++ preprocessor. The .B   **-D**    and .B   **-I**    options need to be placed before .B   **--**   .

## FILES

**file  .{cc,C,c,cpp,cxx,mc}**  source file.

**file  .occ**  output file after C++ preprocessing.

**file  .ii**  output file after translation.

**file  .o**  object file.

**file  .so**  shared library dynamically loaded by   **occ**  .

 **opencxx.a**  library to link with meta-level program.

## NOTES

While the C++ processor is running, the macro   **\_\_opencxx**   is predefined.

The programs compiled by   **occ**   do not need any runtime libraries or a garbage collector unless the meta-level program requires them at the base level.

## COPYRIGHT

Copyright &#169; 1997, 1998 Shigeru Chiba.  All Rights Reserved.\
 Copyright &#169; 1995, 1996 Xerox Corporation.  All Rights Reserved.

## AUTHOR

Shigeru Chiba, University of Tsukuba, Japan.\
 Email: chiba@is.tsukuba.ac.jp
