LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

h2ph

Convert C header files to Perl header files

TLDR

Convert a C header file to Perl
$ h2ph [header.h]
copy
Process all system headers recursively
$ cd /usr/include && h2ph -r -l *.h
copy
Output to a specific directory
$ h2ph -d [/usr/lib/perl5] [header.h]
copy
Convert a header and all headers it includes
$ h2ph -a [sys/types.h]
copy

SYNOPSIS

h2ph [options] [headerfiles...]

DESCRIPTION

h2ph converts C header files (.h) to Perl header files (.ph). It translates #define macros and constant definitions into Perl equivalents that can be loaded with require.The tool is best run from /usr/include to convert system headers. It wraps definitions inside eval blocks so that you can access the definitions it can translate even if some fail. Output .ph files are placed in Perl's architecture-dependent library directory by default.

PARAMETERS

HEADERFILES

C header files (.h) to convert to Perl header files (.ph).
-d DIR
Put resulting .ph files beneath the specified directory instead of the default Perl library location.
-r
Run recursively, converting all .h files in specified directories and their subdirectories.
-a
Run automagically; convert specified headers as well as any .h files they include.
-l
Create symbolic links for duplicate output files instead of separate copies.
-D DIR
Search the specified directory for included header files.
-e
If an error is encountered during conversion, output file names and continue parsing.
-Q
Quiet mode. Do not print the names of converted files.

INSTALL

sudo apt install perl
copy
sudo dnf install perl
copy
sudo pacman -S perl
copy
sudo apk add perl-utils
copy
sudo zypper install perl
copy
brew install perl
copy
nix profile install nixpkgs#perl
copy

CAVEATS

Only handles simple #define constants and macros. Complex C macros, function-like macros, and typedefs are not translated. Output may need manual corrections. The h2xs tool is generally preferred for creating Perl extensions from C headers.

HISTORY

h2ph has been part of the Perl distribution since early versions, providing a quick way to access system constants from Perl programs before XS and h2xs became the preferred approach.

SEE ALSO

h2xs(1), perl(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid