This chapter describes how to run OrgC++ in the single user mode. For a more complicated case where several programmers use OrgC++ simultaneously, see Chap.18.
The general syntax for invoking the class generator is:
orgCpath/zzprep prog.cpp <incl.h> <master> <func.c> <comb.h>
where:
orgCpath is the path to the orgC directory,
prog.cpp is either the total source, or the file containing
object declarations with all ZZ_EXT and ZZ_HYPER
statements,
incl.h is the result of preprocessing (default=zzincl.h),
master is the master table of the chosen library (default=zzmaster).
func.c is the second file produced by the class generator
(default=zzfunc.c).
comb.h is the reduced macro file (default=zzcomb.h).
WARNING: The full path to the orgC directory must be given in the invocation of zzprep. It is not sufficient to set a path to the orgC directory, and then simply call zzprep. The zzprep program needs the full path to derive the locations of some additional files it needs for operation, in particular the file orgC/macro/zzmaster. If you get an error message about the program not being able to read this file, most likely the problem is in how you call zzprep.
Under UNIX, we assume both mySource.c and mySource.cc will be interpreted as C++ source files, depending on the content of the file. Under DOS, it is automatically assumed that mySource.cpp is a C++ file, and that mySource.c is a C source file.
Start your program like this:

Run the whole source through the class generator:
orgC/zzprep mySource.c ... under UNIX
orgC\zzprep mySource.cpp ... under DOS
Compile (under UNIX):
CC mySource.c orgC/lib/zzlib.a
Compile (DOS, TurboC++):
tcc -mm -Lc:\tc\lib -Ic:\tc\include mySource.cpp orgC\lib\zzlib.lib
Compile (DOS, BorlandC++):
bcc -mm -Vt -Lc:\tc\lib -Ic:\tc\include mySource.cpp orgC\lib\zzlib.lib
Compile (DOS, ZortechC++):
ztc -mM mySource.cpp /link orgC\lib\zmlib.lib
EXAMPLE: See test0a.c in your orgC/test directory.
The preprocessor (zzprep) skips over sections of code commented out by either /*...*/ or by //... However, the preprocessor does not react to #ifdef statements. For example, in the following situation
#ifdef SKIP
....some code
#endif
the preprocessor will run through all the code, regardless whether SKIP is defined or not.
The class generator does not have to read all your source, it needs only those sections of your code, and those include files that use ZZ-prefix commands. These commands are ZZ_EXT_.., ZZ_HYPER_.., and possibly ZZ_CHECK(). In OrgC++, such statements are used in class declarations only, and should therefore be concentrated in a few header files.
Regardless of how many source files you use, you proceed in this manner, adding cat (or type under DOS) statements as required:

Combine all your include files into one large file, and run this file through the class generator.
The source files must start like this:!!TODO - Ask Jiri if something is missing.
Then you compile and link your program as usual. Note that instead of including zzfunc.c at the end of the main program, you can compile it separately.
EXAMPLE: test7a.c, test7x.c, and test7.h in your orgC/test directory.
This method has two advantages: (a) the class generator runs faster, because the combined include file is always short compared to the overall source; (b) you don't have to re-run the class generator during debugging, unless you also touch one of your include files. This is a condition which may also be used by the Makefile facility.
Some compilers, especially under DOS, run out of space when applied to a large file which contains many functions. The solution to this problem is to split the file into several files, each containing fewer functions and fewer lines of code.
You can encounter this problem in two situations:
File zzfunc.c is normally out of your control, and even if you edit it manually and split it into several sections, you would have to do the same work again any time zzprep is invoked.
The self-standing program zzsplit allows you to split zzfunc.c into several sections of approximately the same size. All the sections are placed into the same file (default name zzfun.c) with individual sections separated by #ifdef statements:
#ifdef SECTION1 ... #endif #ifdef SECTION2 ... #endif #ifdef SECTION3
... and so on
If you want to compile the first section, create a simple file which contains the following two lines, and compile is separately:
#define SECTION1 #include "zzfun.c"
The general syntax for the zzsplit program is:
zzsplit zzfunc.c zzfun.c inp
where
zzfunc.c is the original (normal) zzfunc.c file;
default: zzfunc.c
zzfun.c is the new file with special ifdefs;
default: zzfun.c
inp is the input file containing one integer, number of required sections;
default: stdin
If you want to split zzfunc.c into 4 sections, and use the defaults for zzfunc.c and zzfun.c, create a simple file inp which contains just one number, 4. Then call
zzsplit inp
This technique is used in test18f, see orgc/test/cregr or one of the other regression files.
| Chapter 10: OrgC++ Library |