h2pas.1 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. .TH h2pas 1 "12 Dec 1999" "Free Pascal" "Free Pascal C header conversion utility"
  2. .SH NAME
  3. h2pas \- The C header to pascal unit conversion program.
  4. .SH SYNOPSIS
  5. .B h2pas
  6. .I "[options] filename"
  7. .SH DESCRIPTION
  8. .B h2pas
  9. attempts to convert a C header file to a pascal unit.
  10. it can handle most C constructs that one finds in a C header file,
  11. and attempts to translate them to their pascal counterparts. see the
  12. .B CONSTRUCTS
  13. section for a full description of what the translator can handle.
  14. .SH USAGE
  15. H2pas is a command-line tool that translates a C header file to a spascal
  16. unit. It reads the C header file and translates the C declarations to
  17. equivalent pascal declarations that can be used to access code written in C.
  18. The output of the h2pas program is written to a file with the same name as
  19. the C header file that was used as input, but with the extension \fI.pp\fP.
  20. The output file that h2pas creates can be customized in a number of ways by
  21. means of many options.
  22. .SH OPTIONS
  23. The output of
  24. .B h2pas
  25. can be controlled with the following options:
  26. .TP
  27. .B \-d
  28. use
  29. .I external;
  30. for all procedure and function declarations.
  31. .TP
  32. .B \-D
  33. use
  34. .B external
  35. .I libname
  36. .B name
  37. .I 'func\_name'
  38. for function and procedure declarations.
  39. .TP
  40. .B \-e
  41. Emit a series of constants instead of an enumeration type for the C
  42. .I enum
  43. construct.
  44. .TP
  45. .B \-i
  46. create an include file instead of a unit (omits the unit header).
  47. .TP
  48. .BI \-l " libname"
  49. specify the library name for external function declarations.
  50. .TP
  51. .BI \-o " outfile"
  52. Specify the output file name. Default is the input file name with
  53. the extension replaced by
  54. .I ".pp"
  55. "."
  56. .TP
  57. .B \-p
  58. use the letter
  59. .B P
  60. in front of pointer type parameters instead of "^".
  61. .TP
  62. .B \-s
  63. Strip comments from the input file. By default comments are converted
  64. to comments, but they may be displaced, since a comment is handled by the
  65. scanner.
  66. .TP
  67. .B \-t
  68. prepend typedef type names with the letter
  69. .B T
  70. (used to follow Borland's convention that all types should be defined with
  71. T).
  72. .TP
  73. .B \-v
  74. replace pointer parameters by call by reference parameters.
  75. Use with care because some calls can expect a NIL pointer.
  76. .TP
  77. .B \-w
  78. Header file is a win32 header file (adds support for some special macros).
  79. .TP
  80. .B \-x
  81. handle SYS\_TRAP of the PalmOS header files.
  82. .SH CONSTRUCTS
  83. The following C declarations and statements are recognized:
  84. .TP
  85. .B defines
  86. defines are changed into pascal constants if they are simple defines.
  87. macros are changed - wherever possible to functions; however the arguments
  88. are all integers, so these must be changed manually. Simple expressions
  89. in define staments are recognized, as are most arithmetic operators:
  90. addition, substraction, multiplication, division, logical operators,
  91. comparision operators, shift operators. The C construct ( A ? B : C)
  92. is also recognized and translated to a pascal construct with an IF
  93. statement (this is buggy, however).
  94. .TP
  95. .B "preprocessor statements"
  96. the conditional preprocessing commands are recognized and translated into
  97. equivalent pascal compiler directives. The special
  98. .B "#ifdef \_\_cplusplus"
  99. is also recognized and removed.
  100. .TP
  101. .B typedef
  102. A typedef statement is changed into a pascal type statement. The following
  103. basic types are recognized:
  104. .RS
  105. .TP
  106. .I char
  107. changed to char.
  108. .TP
  109. .I float
  110. changed to real (=double in free pascal).
  111. .TP
  112. .I int
  113. changed to longint.
  114. .TP
  115. .I long
  116. changed to longint.
  117. .TP
  118. .I "long int"
  119. changed to longint.
  120. .TP
  121. .I short
  122. changed to integer.
  123. .TP
  124. .I unsigned
  125. changed to cardinal.
  126. .TP
  127. .I "unsigned char"
  128. changed to byte.
  129. .TP
  130. .I "unsigned int"
  131. changed to cardinal.
  132. .TP
  133. .I "unsigned long int"
  134. changed to cardinal.
  135. .TP
  136. .I "unsigned short"
  137. changed to word.
  138. .TP
  139. .I void
  140. ignored.
  141. .RE
  142. These types are also changed if they appear in the arguments of a function
  143. or procedure.
  144. .TP
  145. .B "functions and procedures"
  146. functions and procedures are translated as well; pointer types may be
  147. changed to call by reference arguments (using the
  148. .B var
  149. argument) by using the
  150. .B \-p
  151. command line argument. functions that have a variable number of arguments
  152. are changed to a function with an
  153. .B "array of const"
  154. argument.
  155. .TP
  156. .B specifiers
  157. the
  158. .I extern
  159. specifier is recognized; however it is ignored. the
  160. .I packed
  161. specifier is also recognised and changed with the
  162. .I PACKRECORDS
  163. directive. The
  164. .I const
  165. specifier is also recognized, but is ignored.
  166. .TP
  167. .B modifiers
  168. If the
  169. .B \-w
  170. option is specified, then the following modifiers are recognized:
  171. .I STDCALL
  172. ,
  173. .I CDECL
  174. ,
  175. .I CALLBACK
  176. ,
  177. .I PASCAL
  178. ,
  179. .I WINAPI
  180. ,
  181. .I APIENTRY
  182. ,
  183. .I WINGDIAPI
  184. as defined in the win32 headers.
  185. If additionally the
  186. .B \-x
  187. option is specified then the
  188. .I SYS\_TRAP
  189. specifier is also recognized.
  190. .TP
  191. .B enums
  192. enum constructs are changed into enumeration types; bear in mind that in C
  193. enumeration types can have values assigned to them; Free Pascal also allows
  194. this to a certain degree. If you know that values are assigned to enums, it
  195. is best to use the
  196. .B \-e
  197. option to change the enus to a series of integer constants.
  198. .TP
  199. .B unions
  200. unions are changed to variant records.
  201. .TP
  202. .B structs
  203. are changed to pascal records, with
  204. .B C
  205. packing.
  206. .IP
  207. .SH SEE ALSO
  208. .IP
  209. .BR ppc386 (1)
  210. .BR ppumove (1)