Search code examples
cxcodeh3

Safe to truncate .in file extension for C header file?


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


Solution

  • 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.