Translating C headers
 


A FreeBASIC header should expose the C library interface accurately while still
looking like normal FreeBASIC source. Start from the C declarations, translate
types and calling conventions carefully, then keep platform-specific differences
visible instead of hiding them behind guesses.

Basic process

  • Identify the library version and platform ABI being translated.
  • Translate constants, enums, structs, unions, callbacks, and functions.
  • Use the C type comparison table for integer, pointer, string, and size
types.
  • Keep conditional declarations close to the platform condition that requires
them.
  • Compile small examples against the header on the target platform.

Useful pages

::TblComparisonCTypes|C type comparison table::
::DevHeaderStyleGuide|Header style guide::
::DevBindingCreation|Creating bindings::