免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5492 | 回复: 3
打印 上一主题 下一主题

unix 下C 语言 include 搜索的路径的设置在什么地方啊 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-04-11 17:17 |只看该作者 |倒序浏览
unix 下C 语言 include 搜索的路径的设置  在什么地方啊     

论坛徽章:
0
2 [报告]
发表于 2005-04-20 10:59 |只看该作者

unix 下C 语言 include 搜索的路径的设置在什么地方啊

我也是新手,说的不一定正确,如果不对,不要见笑。
我想着要看你用什末工具,如果用make,则在makefile中用全路径或环境变量路径说明。如果用forte c中的workshop,则在.prd 文件中说明。

论坛徽章:
0
3 [报告]
发表于 2005-04-20 11:09 |只看该作者

unix 下C 语言 include 搜索的路径的设置在什么地方啊

只知道gcc好多参数可以增设系统的,设定非系统的。

一直想知道如果采用默认,gcc都会查询哪些路径,如何永久添加/删除这些路径。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2005-04-20 12:54 |只看该作者

unix 下C 语言 include 搜索的路径的设置在什么地方啊

我把gcc设置默认搜索目录的程序放这里,
有兴趣研究一下吧,我也没怎么看。
这是gcc-3.4.3
cppdefault.h

  1. /* CPP Library.
  2.    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  3.    1999, 2000, 2003 Free Software Foundation, Inc.
  4.    Contributed by Per Bothner, 1994-95.
  5.    Based on CCCP program by Paul Rubin, June 1986
  6.    Adapted to ANSI C, Richard Stallman, Jan 1987

  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.

  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.

  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

  18. #ifndef GCC_CPPDEFAULT_H
  19. #define GCC_CPPDEFAULT_H

  20. /* This is the default list of directories to search for include files.
  21.    It may be overridden by the various -I and -ixxx options.

  22.    #include "file" looks in the same directory as the current file,
  23.    then this list.
  24.    #include <file>; just looks in this list.

  25.    All these directories are treated as `system' include directories
  26.    (they are not subject to pedantic warnings in some cases).  */

  27. struct default_include
  28. {
  29.   const char *const fname;        /* The name of the directory.  */
  30.   const char *const component;        /* The component containing the directory
  31.                                    (see update_path in prefix.c) */
  32.   const char cplusplus;                /* Only look here if we're compiling C++.  */
  33.   const char cxx_aware;                /* Includes in this directory don't need to
  34.                                    be wrapped in extern "C" when compiling
  35.                                    C++.  */
  36.   const char add_sysroot;        /* FNAME should be prefixed by
  37.                                    cpp_SYSROOT.  */
  38. };

  39. extern const struct default_include cpp_include_defaults[];
  40. extern const char cpp_GCC_INCLUDE_DIR[];
  41. extern const size_t cpp_GCC_INCLUDE_DIR_len;

  42. extern const char *cpp_SYSROOT;

  43. #endif /* ! GCC_CPPDEFAULT_H */
复制代码



cppdefault.c

  1. /* CPP Library.
  2.    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  3.    1999, 2000, 2003 Free Software Foundation, Inc.
  4.    Contributed by Per Bothner, 1994-95.
  5.    Based on CCCP program by Paul Rubin, June 1986
  6.    Adapted to ANSI C, Richard Stallman, Jan 1987

  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.

  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.

  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

  18. #include "config.h"
  19. #include "system.h"
  20. #include "coretypes.h"
  21. #include "tm.h"
  22. #include "cppdefault.h"

  23. #ifndef STANDARD_INCLUDE_DIR
  24. #define STANDARD_INCLUDE_DIR "/usr/include"
  25. #endif

  26. #ifndef STANDARD_INCLUDE_COMPONENT
  27. #define STANDARD_INCLUDE_COMPONENT 0
  28. #endif

  29. #if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT)
  30. # undef LOCAL_INCLUDE_DIR
  31. # undef SYSTEM_INCLUDE_DIR
  32. # undef STANDARD_INCLUDE_DIR
  33. #else
  34. # undef CROSS_INCLUDE_DIR
  35. #endif

  36. const struct default_include cpp_include_defaults[]
  37. #ifdef INCLUDE_DEFAULTS
  38. = INCLUDE_DEFAULTS;
  39. #else
  40. = {
  41. #ifdef GPLUSPLUS_INCLUDE_DIR
  42.     /* Pick up GNU C++ generic include files.  */
  43.     { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0 },
  44. #endif
  45. #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
  46.     /* Pick up GNU C++ target-dependent include files.  */
  47.     { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0 },
  48. #endif
  49. #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
  50.     /* Pick up GNU C++ backward and deprecated include files.  */
  51.     { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0 },
  52. #endif
  53. #ifdef LOCAL_INCLUDE_DIR
  54.     /* /usr/local/include comes before the fixincluded header files.  */
  55.     { LOCAL_INCLUDE_DIR, 0, 0, 1, 1 },
  56. #endif
  57. #ifdef PREFIX_INCLUDE_DIR
  58.     { PREFIX_INCLUDE_DIR, 0, 0, 1, 0 },
  59. #endif
  60. #ifdef GCC_INCLUDE_DIR
  61.     /* This is the dir for fixincludes and for gcc's private headers.  */
  62.     { GCC_INCLUDE_DIR, "GCC", 0, 0, 0 },
  63. #endif
  64. #ifdef CROSS_INCLUDE_DIR
  65.     /* One place the target system's headers might be.  */
  66.     { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0 },
  67. #endif
  68. #ifdef TOOL_INCLUDE_DIR
  69.     /* Another place the target system's headers might be.  */
  70.     { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0 },
  71. #endif
  72. #ifdef SYSTEM_INCLUDE_DIR
  73.     /* Some systems have an extra dir of include files.  */
  74.     { SYSTEM_INCLUDE_DIR, 0, 0, 0, 1 },
  75. #endif
  76. #ifdef STANDARD_INCLUDE_DIR
  77.     /* /usr/include comes dead last.  */
  78.     { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 1 },
  79. #endif
  80.     { 0, 0, 0, 0, 0 }
  81.   };
  82. #endif /* no INCLUDE_DEFAULTS */

  83. #ifdef GCC_INCLUDE_DIR
  84. const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
  85. const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
  86. #else
  87. const char cpp_GCC_INCLUDE_DIR[] = "";
  88. const size_t cpp_GCC_INCLUDE_DIR_len = 0;
  89. #endif

  90. #ifdef TARGET_SYSTEM_ROOT
  91. const char *cpp_SYSROOT = TARGET_SYSTEM_ROOT;
  92. #else
  93. const char *cpp_SYSROOT = "";
  94. #endif
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP