rwallace rwallace - 6 months ago 35
C Question

Finding out what the GCC include path is

I'm trying to programmatically find the

path on Linux, which as I understand it, in practice means finding what GCC considers it to be. (Is that quite true? How does Clang do it?)

According to some of the components involve the CPU architecture and the GCC version; the latter in particular seems tricky; I suppose it could be obtained by running
gcc --version
and parsing the output (or
gcc -v
), but this seems inelegant at best and fragile at worst. Doing it from within one's code assuming one's program is being compiled with GCC might be another option, but it would require depending on that assumption.

What's the recommended way to do it?

caf caf

The command

echo | gcc -E -Wp,-v -

will show the include path in use.