Consider the following program, which resides in a directory different
from $HOME.  Call it test.c, and put an empty test.h into $HOME.

  #include "test.h"
  #include <stdio.h>

  int main() { printf("hi"); }

If one tries to compile this, GCC issues an error (So far so good):

  % gcc x.c
  x.c:1:18: test.h: No such file or directory

So I set C_INCLUDE_PATH accordingly and, still as expected, get:

  % export C_INCLUDE_PATH=$HOME ; gcc x.c
  %

However, once I use the g++ driver to compile this program the error
is back:

  % g++ x.c
  x.c:1:18: test.h: No such file or directory

Which I believe contradicts the following from cppenv.texi, since even
though we use the g++ driver, the program still is compiled as C input:

  The[se] environment variables apply only when preprocessing the
  particular language indicated. 

Interestingly, though, the preprocessor does set __cplusplus, so it
seems g++ preprocesses .c files as C++, but then compiles them as C.

Feature, bug, or potential to improve documentation?

Gerald

Reply via email to