In my code I use a header file which unfortunately has a different location under different Linux distributions.
In my case it is fitsio.h from cfitsio which is located here in OpenSUSE 12.1:
#include <cfitsio/fitsio.h>
and here in Arch Linux:
#include <fitsio.h>
I guess I can use some preprocessor directives to create a switch. I can use this to test if I am on Linux or Windows, etc. but I have no clue what I can use to test whether I am on Arch Linux or not.
Or is there another way/strategy to handle this case?
To avoid multiple inclusions of the same header file we use the #ifndef, #define and #endif preprocessor directives. Just write the entire program in only file and include headers once only. You can use the conditional preprocessor directive named #ifndef to check whether that symbolic name has already been assigned.
The C library's header files include the kernel header files from the “linux” subdirectory. The system's libc headers are usually installed at the default location /usr/include and the kernel headers in subdirectories under that (most notably /usr/include/linux and /usr/include/asm).
The angle brackets (<>) cause the preprocessor to search for the header file in the standard place for header files on your system, usually the /usr/include directory.
gcc -I adds include directory of header files.
Keep the simpler include
#include <fitsio.h>
Then, under additional include directories, list paths to directories containing this header both for SUSE and for Arch:
/path/to/header/cfitsio
/path/to/header
Even if the former is nonexistent on Arch, it won't lead to any problems during compilation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With