1

I've imported a C library into my Swift project (in Xcode) from Uber's H3 (their geospatial library). Everything works as expected, however, the main header file has a .in file extension suffix which I had to truncate from h3api.h.in to h3api.h. I understand the .in extension is for some kind of file configurator but all I'm doing is dragging and dropping the .c and .h files directly into my project without any sort of auto file generation.

Can I safely truncate the .in file extension suffix of this main header file before importing into my project? Again, everything works as expected but are there any unintended side effects?

Here is the file in question: https://github.com/uber/h3/blob/master/src/h3lib/include/h3api.h.in

lurning too koad
  • 2,698
  • 1
  • 17
  • 47

1 Answers1

3

I understand the .in extension is for some kind of file configurator but all I'm doing is dragging and dropping the .c and .h files directly into my project without any sort of auto file generation.

Your intuition is correct: h3api.h.in is meant to be preprocessed to generate the h3api.h tailored for your system.

Can I safely truncate the .in file extension suffix of this main header file before importing into my project? Again, everything works as expected but are there any unintended side effects?

It is difficult to tell without a thorough analysis of both the h3api.h.in file and your own source code (and a good understanding of what the swift compiler reads from the C header files).

The original file contains configuration variables with a syntax @VARIABLE_NAME@ but you seem to be lucky as the only definitions that get configured by the preprocessor are these:

#define H3_VERSION_MAJOR @H3_VERSION_MAJOR@
#define H3_VERSION_MINOR @H3_VERSION_MINOR@
#define H3_VERSION_PATCH @H3_VERSION_PATCH@

As long as you do not use these symbols, you should be fine.

chqrlie
  • 131,814
  • 10
  • 121
  • 189
  • Is there a way to generate this file through Xcode or macOS (Terminal perhaps) to see what changes were made from the input version? – lurning too koad Mar 19 '23 at 16:15
  • 1
    @lurningtookoad: You can clone the repository and try and run `./configure` from the terminal. But there might be many dependencies that will make your life miserable. If everything works fine in your swift project, don't worry about it in this particular case. – chqrlie Mar 19 '23 at 16:16
  • Real quick, what syntax in the input file would I be looking for if I wanted to get an idea of what sorts of instructions the input file has requested? Maybe the input file just wants to know if the project is in a Windows environment, no? – lurning too koad Mar 19 '23 at 16:23
  • @lurningtookoad: As I wrote in the answer, the syntax seems to be `@[A-Za-z0-9_]+@`. Searching for this regular expression produces only the 3 definitions posted in the answer. A typical case of over-engineering. – chqrlie Mar 19 '23 at 16:26