Search code examples
gccqnxqnx-neutrinoblackberry-qnx

Inserting header file during compile time


I'm trying to compile a library but some macros are missing. I want to add these macros, which are located in a header file, during compile time. gcc has an include option like below:

gcc  ...  -include <macros.h> ...

How could I achieve this in QNX? I couldn't find an qcc option to add header file.


Solution

  • In case you would like to define a path to the headers file to include, you have to use the -I option by defining where the header files are located:

    qcc ... -I<<path_to_header_files>> ...
    

    Otherwise, in case you don't want to insert the #include directive in every file that uses the macros defined in a specific header file, you can use the following compiler option:

    qcc -Wp, -include<<path_to_header_file/file.h>> ...
    

    In this way you are telling to the compiler that during the preprocessing phase (-Wp) it has to include the header file specified after the -include argument.