1
.TH h2pas 1 "12 Dec 1999" "Free Pascal" "Free Pascal C header conversion utility"
3
h2pas \- The C header to pascal unit conversion program.
8
.I "[options] filename"
13
attempts to convert a C header file to a pascal unit.
14
it can handle most C constructs that one finds in a C header file,
15
and attempts to translate them to their pascal counterparts. see the
17
section for a full description of what the translator can handle.
21
H2pas is a command-line tool that translates a C header file to a spascal
22
unit. It reads the C header file and translates the C declarations to
23
equivalent pascal declarations that can be used to access code written in C.
25
The output of the h2pas program is written to a file with the same name as
26
the C header file that was used as input, but with the extension \fI.pp\fP.
27
The output file that h2pas creates can be customized in a number of ways by
28
means of many options.
34
can be controlled with the following options:
41
for all procedure and function declarations.
49
for function and procedure declarations.
52
Emit a series of constants instead of an enumeration type for the C
57
create an include file instead of a unit (omits the unit header).
60
specify the library name for external function declarations.
63
Specify the output file name. Default is the input file name with
64
the extension replaced by
71
in front of pointer type parameters instead of "^".
74
Strip comments from the input file. By default comments are converted
75
to comments, but they may be displaced, since a comment is handled by the
79
prepend typedef type names with the letter
81
(used to follow Borland's convention that all types should be defined with
85
replace pointer parameters by call by reference parameters.
86
Use with care because some calls can expect a NIL pointer.
89
Header file is a win32 header file (adds support for some special macros).
92
handle SYS\_TRAP of the PalmOS header files.
95
The following C declarations and statements are recognized:
99
defines are changed into pascal constants if they are simple defines.
100
macros are changed - wherever possible to functions; however the arguments
101
are all integers, so these must be changed manually. Simple expressions
102
in define staments are recognized, as are most arithmetic operators:
103
addition, substraction, multiplication, division, logical operators,
104
comparision operators, shift operators. The C construct ( A ? B : C)
105
is also recognized and translated to a pascal construct with an IF
106
statement (this is buggy, however).
109
.B "preprocessor statements"
110
the conditional preprocessing commands are recognized and translated into
111
equivalent pascal compiler directives. The special
112
.B "#ifdef \_\_cplusplus"
113
is also recognized and removed.
118
A typedef statement is changed into a pascal type statement. The following
119
basic types are recognized:
126
changed to real (=double in free pascal).
149
.I "unsigned long int"
158
These types are also changed if they appear in the arguments of a function
161
.B "functions and procedures"
162
functions and procedures are translated as well; pointer types may be
163
changed to call by reference arguments (using the
165
argument) by using the
167
command line argument. functions that have a variable number of arguments
168
are changed to a function with an
175
specifier is recognized; however it is ignored. the
177
specifier is also recognised and changed with the
181
specifier is also recognized, but is ignored.
187
option is specified, then the following modifiers are recognized:
201
as defined in the win32 headers.
204
option is specified then the
206
specifier is also recognized.
210
enum constructs are changed into enumeration types; bear in mind that in C
211
enumeration types can have values assigned to them; Free Pascal also allows
212
this to a certain degree. If you know that values are assigned to enums, it
215
option to change the enus to a series of integer constants.
219
unions are changed to variant records.
223
are changed to pascal records, with