超级简单问题--关于VC++.net中include的问题。

xinglinshu 2006-03-28 04:39:29
#include "***.h"
#include <***.h>
这两者的区别是什么?
"***.h"是当前工程所在目录。
<***.h>是指定的目录?如果是,在那设置!
...全文
176 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
independently 2006-03-31
  • 打赏
  • 举报
回复
找寻此被包含的文件的路径的顺序有些不同.
双引号""表示预处理器将先找寻目前所在目录的文件,如果找不到,再找编译器指定的include路径及系统INCLUDE环境变量指定的路径.
如果是<>表示预处理器直接找寻编译器指定的include路径,再找INCLUDE环境变量所指的路径.
如果双引号内写入完整的路径名称,编译器只会在指定的路径下找不会去系统INCLUDE路径
xinglinshu 2006-03-28
  • 打赏
  • 举报
回复
include".h" 是定义在工程的头文件里
但include<.h> 没有定义在头文件里,但确实是自己写的。原程序中就直接写的include<.h>还有include<****/****.h>,但这些头文件我却不知道该放到哪里去。
注:我是在修改别人的程序,但环境一直配不好。
independently 2006-03-28
  • 打赏
  • 举报
回复
你是在把include".h" 定义在工程的头文件里吗
xinglinshu 2006-03-28
  • 打赏
  • 举报
回复
那我把它放在哪里呢?无论我放到当前工程的文件夹里还是放到别处凑报错,说找不着该文件。
xinglinshu 2006-03-28
  • 打赏
  • 举报
回复
那我把它放在哪里呢?放到当前工程里就报错。放到别处又找不着。
independently 2006-03-28
  • 打赏
  • 举报
回复
不用管它,其实他们区别都不大,也就搜索路径时他们不一样,先搜寻系统的,再搜寻自定义的。
xinglinshu 2006-03-28
  • 打赏
  • 举报
回复
当我遇到的<>中的头文件也是自定义的,那该怎么办?
independently 2006-03-28
  • 打赏
  • 举报
回复
The #include directive tells the preprocessor to treat the contents of a
specified file as if those contents had appeared in the source program at
the point where the directive appears. You can organize constant and macro
definitions into include files and then use #include directives to add these
definitions to any source file. Include files are also useful for
incorporating declarations of external variables and complex data types. You
need to define and name the types only once in an include file created for
that purpose.

#include "path-spec"
#include <path-spec>
The path-spec is a filename optionally preceded by a directory
specification. The filename must name an existing file. The syntax of the
path-spec depends on the operating system on which the program is compiled.


Both syntax forms cause replacement of that directive by the entire contents
of the specified include file. The difference between the two forms is the
order in which the preprocessor searches for header files when the path is
incompletely specified.


Syntax Form Action
Quoted form This form instructs the preprocessor to look for include
files in the same directory of the file that contains the #include
statement, and then in the directories of any files that include (#include)
that file. The preprocessor then searches along the path specified by the /I
compiler option, then along paths specified by the INCLUDE environment
variable.
Angle-bracket form This form instructs the preprocessor to search for
include files first along the path specified by the /I compiler option,
then, when compiling from the command line, along the path specified by the
INCLUDE environment variable.


independently 2006-03-28
  • 打赏
  • 举报
回复
<>是系统定义头文件,""中是自己定义的

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧