1

when we use #include < stdio.h > in linux platform, the compiler will search the stdio.h in /usr/include. How to change the path of using #include<>? thank you.

I asked the question because of this : when I use the C standard function isdigit(), if "#include< ctype.h >" is not added, the program generates a warning but no error. But if "#include < ctype.h >" is added,it will generate an error when linking.(My compiler is not the standard gcc.)

I wonder why?

vv1133
  • 739
  • 1
  • 8
  • 21
  • 1
    For standard Libc headers I would avoid doing that. You need the `` paired with your `libc.so`. You can have big trouble if you change it, unless you understand very well what you are doing. – Basile Starynkevitch Nov 08 '11 at 12:38
  • possible duplicate of [How to include header files in GCC search path?](http://stackoverflow.com/questions/973146/how-to-include-header-files-in-gcc-search-path) – CharlesB Nov 08 '11 at 12:40

2 Answers2

5
 -I dir
     Add the directory dir to the list of directories to be
     searched for header files.  Directories named by -I are
     searched before the standard system include directories.
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
1

There are 2 different ways:

  1. Use -Idir in the Makefile or as an argument to gcc.

  2. Create environment variable C_INCLUDE_PATH (for C header files) or CPLUS_INCLUDE_PATH (for C++ header files).

Igor
  • 26,650
  • 27
  • 89
  • 114