Who to deal with *.h.in files

Hi all,

i never really used c and no next to nothing about project with more than a main.c file.

I tried to build the graphics tool kit tcl/tk and after a while i got errors that the “tkUuid.h” file is missing, there is however a tkUuid.h.in file.

When i tried to build wx widgets a came across the same issue.

My question is: how do you get the .h file from the .h.in file?

You can use addConfigHeader to generate the .h file from a .h.in file.
In the resulting ConfigHeader call the addValues to configure the parameters.
Finally call addConfigHeader.

Example usage:

4 Likes

Explanations of config header generation is in the Build System Tips and Tricks Doc on Ziggit as well!

1 Like

To expand upon this post:

.in files usually represent files that contain placeholder values that should be modified by the build system depending on which build options the user specified. Different build systems use different syntaxes:

  • Autoconf uses #undef FOO.
  • CMake uses #cmakedefine FOO and @FOO@.
  • Meson uses #mesondefine FOO and @FOO@ (Zig does not yet support this syntax).

To determine which style to specify, look at which build system the upstream project uses (or go by the syntax of the .in file).

Note that this project linked by @dimdin uses the .blank style, which just writes the names and values to a new file line by line instead of modifying an existing .in file. For an example of the .autoconf style, see
https://github.com/allyourcodebase/cpython/blob/3b579aeb401290e483bbe2c6e0d26f4679d2bf8a/build.zig#L33
and the corresponding .in file
https://github.com/allyourcodebase/cpython/blob/3b579aeb401290e483bbe2c6e0d26f4679d2bf8a/pyconfig.h.in.

2 Likes