Question

Is it just to test compile a simple program, with that header file #included in it?

To better understand the compilation process I'm writing my own "configure", which tests for the existence of a few header and library files.

Was it helpful?

Solution

Yes, use the compiler to compile your simple test program. That's the best and easiest way to see if the compiler can find the header. If you hard code #include search paths you'll always have to modify and adapt for different compilers.

OTHER TIPS

The GNU Autoconf suite checks for headers by running test compilations. Just testing for the existence of a file 'filename.h' is fairly simple:

#include <filename.h>
int main(void){return 0;}

You might prefer quotes instead of angle brackets.

Using the following program ,you can find the existence of the header file.

#include<stdio.h>
main()
{
        FILE * file;
        if ((file = fopen("/usr/include/stdio.h", "r"))!=NULL)
        {
                fclose(file);
                printf("true");
        }
        perror("err");

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top