occ --- the Open C++ compiler
occ [-l] [-s] [-V] [-v] [-m[file_name]] [-c] [-E] [-n] [-p] [-P] [-Iinclude_directory] [-Dname[=def]] [-Moption[=value]] [-Smetaclass] [-doption] [--regular-c++] [-- C++ compiler options [.o and .a files]] source_file
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
For the reason of efficiency, the user can statically link the 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.
% occ -I.. -- -g foo.c
Copyright © 1997-99 Shigeru Chiba. All Rights Reserved.
Copyright © 1995, 1996 Xerox Corporation. All Rights Reserved.
Shigeru Chiba, University of Tsukuba, Japan.