h2pas(1)
β¨ NAME β¨
h2pas β the C header to pascal unit conversion program, bestie. literally what it says on the tin π
π¦ SYNOPSIS π¦
h2pas [options] filename
πΈ DESCRIPTION πΈ
okay so h2pas attempts to convert a C header file into a pascal unit. it can handle most C constructs that one finds in a C header file, and it attempts to translate them into their pascal counterparts. if you wanna know exactly what this translator can and can't deal with, go read the CONSTRUCTS section below, fr fr. π
π USAGE π
H2pas is a command-line tool that translates a C header file into a pascal unit. it reads the C header file and translates the C declarations into equivalent pascal declarations that you can use to access code written in C. iconic behaviour honestly.
the output of the h2pas program gets written to a file with the same name as the C header file that was used as input, but with the extension .pp. and the way that output file can be customized?? so many ways, by means of many options. we love options. π
β¨ OPTIONS β¨
the output of h2pas can be controlled with the following options:
-dβ useexternal;for all procedure and function declarations.-Dβ useexternal libname name 'func_name'for function and procedure declarations.-eβ emit a series of constants instead of an enumeration type for the Cenumconstruct.-iβ create an include file instead of a unit (omits the unit header).-llibname β specify the library name for external function declarations.-ooutfile β specify the output file name. default is the input file name with the extension replaced by.pp.-pβ use the letterPin front of pointer type parameters instead of^.-sβ strip comments from the input file. by default comments are converted to comments, but they may be displaced, since a comment is handled by the scanner. π-tβ prepend typedef type names with the letterT(used to follow Borland's convention that all types should be defined withT).-vβ replace pointer parameters by call by reference parameters. use with care because some calls can expect aNILpointer. β οΈ-wβ header file is a win32 header file (adds support for some special macros).-xβ handleSYS_TRAPof the PalmOS header files.
π CONSTRUCTS π
the following C declarations and statements are recognized:
defines
defines are changed into pascal constants if they are simple defines. macros are changed β wherever possible β to functions; however the arguments are all integers, so these must be changed manually. simple expressions in define statements are recognized, as are most arithmetic operators: addition, subtraction, multiplication, division, logical operators, comparison operators, shift operators. the C construct ( A ? B : C) is also recognized and translated to a pascal construct with an IF statement (this is buggy, however). π
preprocessor statements
the conditional preprocessing commands are recognized and translated into equivalent pascal compiler directives. the special #ifdef __cplusplus is also recognized and removed.
typedef
a typedef statement is changed into a pascal type statement. the following basic types are recognized:
charβ changed tochar.floatβ changed toreal(=doublein free pascal).intβ changed tolongint.longβ changed tolongint.long intβ changed tolongint.shortβ changed tointeger.unsignedβ changed tocardinal.unsigned charβ changed tobyte.unsigned intβ changed tocardinal.unsigned long intβ changed tocardinal.unsigned shortβ changed toword.voidβ ignored.
these types are also changed if they appear in the arguments of a function or procedure. π«Ά
functions and procedures
functions and procedures are translated as well; pointer types may be changed to call by reference arguments (using the var argument) by using the -p command line argument. functions that have a variable number of arguments are changed to a function with an array of const argument.
specifiers
the extern specifier is recognized; however it is ignored. the packed specifier is also recognised and changed with the PACKRECORDS directive. the const specifier is also recognized, but is ignored.
modifiers
if the -w option is specified, then the following modifiers are recognized: STDCALL, CDECL, CALLBACK, PASCAL, WINAPI, APIENTRY, WINGDIAPI as defined in the win32 headers. if additionally the -x option is specified then the SYS_TRAP specifier is also recognized.
enums
enum constructs are changed into enumeration types; bear in mind that in C enumeration types can have values assigned to them; Free Pascal also allows this to a certain degree. if you know that values are assigned to enums, it is best to use the -e option to change the enums to a series of integer constants. π
unions
unions are changed to variant records.
structs
are changed to pascal records, with C packing.
π SEE ALSO π
and that's the whole vibe check, bestie π¦ this was Free Pascal, dated 12 Dec 1999 β go convert some headers, you got this, periodt πβ¨
π¦ where this page comes from
- debian bookworm: fp-utils-3.2.2 3.2.2+dfsg-20 Β· GPL-2.0-or-later
- debian trixie: fp-utils-3.2.2 3.2.2+dfsg-46 Β· GPL-2.0-or-later
- ubuntu jammy: fp-utils-3.2.2 3.2.2+dfsg-9ubuntu1 Β· GPL-2.0-or-later
- ubuntu noble: fp-utils-3.2.2 3.2.2+dfsg-32 Β· GPL-2.0-or-later
- ubuntu questing: fp-utils-3.2.2 3.2.2+dfsg-46
- ubuntu resolute: fp-utils-3.2.2 3.2.2+dfsg-49 Β· GPL-2.0-or-later
- ubuntu stonking: fp-utils-3.2.2 3.2.2+dfsg-51 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms