Download The Ch Language Environment SDK User's Guide
Transcript
Chapter C: Commands
c2chf
-v Print out the processed functoins and statistics.
-s Allow the user to specify a typedefed structure name as return type for a function returning a structure.
This option can be used multiple times for different typedefed structure names.
-l To handle functions with variable number of arguments. The function func() of a variable number of
arguments and its corresponding function vfunc() with a fixed number of arguments are specified
following option -l. This option can be used multiple times for multiple functions with variable
number of arguments.
Notes
1. The header may need to be cleaned up first. Comments can remain but all preprocessor directives,
such as #define and typedefs, must be removed manually or using function processhfile().
2. If a directory already exists with the same name as the current header file or user specified directory,
the directory will be used. The .chf files and chdl.c file will be overwritten if they exist.
3. The command c2chf can handle functions with arguments of pointer to structure or or functions that
return a pointer to structure. It can handle functions with arguments of structure type.
4. Although .chf and chdl functions for a function returning structure type are different from those for
refular functions as described in section 5.6, the command c2chf also can handle a function that
returns structure if the function return type is represented in the form of struct tagname. If the
function return type is represented using a typedefed structure name such as structdefname, the
option -s structdefname needs to be used.
5. Similar to handling functions returning structure type, the command c2chf can also handle function
with variable number arguments such as int func(int i, ...), if there is a corresponding
function of int vfunc(int i, va list ap) as described in 5.5. Otherwise, it needs to be
handled manually.
6. The command c2chf cannot handle functions with argument type of pointer to function or functions
that return pointer to function. These specicial functions need to be handled manually and they need
to be removed from a header file using function or using function removeFuncProto(), before the
header file can be processed by the command c2chf.
Example 1
How to include a header file in a .c and .chf file.
c2chf example.h -i c header1.h -i chf header2.h
Example 2
Multiple -i statements are acceptable. The following example shows how to include a user specified
handle in the .chf files and specify directories for the output files:
c2chf example.h -h Chexample handle -o c temp dir c -o chf temp dir chf
Example 3
The commands below
processhfile("extern", 0, ";", "math.h", "chfcreate/math.h", NULL);
c2chf chfcreate/math.h -h _Chmath_handle -r math_err -o c c
\
-o chf chf -s structdef_t -l func5 vfunc5
350