标题包含风格 [英] Header Inclusion style

查看:63
本文介绍了标题包含风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在我的实现文件(.C文件)中包含标题(.h文件),例如

#include" myHeader.h",

,那么''myHeader.h''恰当地包含了
。但是,当我把它包括在内时,就像

#include< myHeader.h>一样,编译器会出错。


我需要做什么设置才能做到这一点,后面的语法也接受了我的标题的

If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then ''myHeader.h'' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?

推荐答案

qazmlp写道:
如果我在我的实现文件(.C文件)中包含类似
#include" myHeader.h",
的标题(.h文件),则''myHeader.h''正确 #include< myHeader.h>中时,编译器会出错。

我需要做什么设置,后者语法也接受
我的标题?
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then ''myHeader.h'' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?




[仅在clc中回复]


你应该不知道的。后一种语法保留用于

标准标题(在术语的ISO C含义中),以及您的

实现愿意考虑标准的任何标题。


您自己的标题只是您自己的标题,并且应始终包含在

#include" foo.h"语法。


-

Bertrand Mollinier Toublet

现实存在 - Richard Heathfield,2003年7月1日



[replied only in c.l.c]

None that you should know about. The latter syntax is reserved for
standard headers (in the ISO C meaning of the term), and any header your
implementation is willing to consider standard.

Your own headers are your own only, and should always be included with
the #include "foo.h" syntax.

--
Bertrand Mollinier Toublet
"Reality exists" - Richard Heathfield, 1 July 2003


qa * *******@rediffmail.com (qazmlp)写道:
qa********@rediffmail.com (qazmlp) wrote:
如果我包括标题(.h文件),如
#include" myHeader.h" ;,
在我的实现文件(.C文件)中,然后正确地包含''myHeader.h''。但是,当我将它包含在
#include< myHeader.h>中时,编译器会出错。

我需要做什么设置,后者语法也接受
我的标题?
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then ''myHeader.h'' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?




< ...>符号在标准位置找到标题,因此

系统标题,而不是你提供的那些,将会找到


......符号可能首先在当前工作的
目录中查找,因此将包含您提供的标题,

,然后查看< ...>的相同位置看起来。


这意味着你可能想要使用不同的符号

因此,


#include< ; stdio.h中>平台提供的/ *标题* /

#include" myhdr.h>程序提供的/ *标题* /


使用unix样式编译器,您还可以选择将编译器认为的位置添加到

。标准,通常带有

-I选项。因此,使用'-I./include''

调用编译器将导致< ...>也可以在./include

目录中查找标题。


你一定要阅读你的文件

编译器。您还可以寻找一个选项,告诉您

更多关于它在做什么。例如,使用GNU C

编译器,gcc,你可以给它-v选项,它将会b / b
详细解释它在做什么以及它在哪里搜索

标题(和库,等等)。


-

Floyd L. Davidson< http:// web .newsguy.com / floyd_davidson>

Ukpeagvik(阿拉斯加州巴罗市) fl***@barrow.com


2003年7月7日,qazmlp写道:
On 7 Jul 2003, qazmlp wrote:
如果我包括标题(.h文件),如
#include" myHeader.h",
在我的实现文件(.C文件)中,然后''myHeader.h''正确包含在内。但是,当我将它包含在
#include< myHeader.h>中时,编译器会出错。

我需要做什么设置,后者语法也接受
我的标题?
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then ''myHeader.h'' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?




搜索到的地点是两种格式的实现定义。你必须查询你的编译器文档,找出它在哪里搜索

的不同标题。


通常,#include< file.h>将搜索系统头文件和

#include" file.h"将搜索项目头文件,然后搜索系统

头文件。


为什么使用#include< file.h>这一点很重要找到你的标题

文件?如果我查看您的源代码,我会假设头文件是某个编译器的特定于实现的头文件。它不会立即发生在我身上,因为它是一个项目头文件。当我看到

#include" file.h"我立即认为这是由

项目程序员而不是编译器公司创建的文件。这是所有jut

惯例,但是有了约定,你可以更轻松地使用

其他人。


-

main(){int j = 1234; char t [] =":@ abcdefghijklmnopqrstuvwxyz。\ n",* i =

" iqgbgxmdbjlgdv.lksrqek.n" ; char * strchr(const char *,int); while(

* i){j + = strchr(t,* i ++) - t; j%= sizeof t-1; putchar(t [ j]);}返回0;}



The places searched are implementation defined for both formats. You''d
have to consult your compiler documentation to find out where it searches
for the different headers.

Typically, #include <file.h> will search the system header files and
#include "file.h" will search the project header files and then the system
header files.

Why is it important that you use #include <file.h> to find your header
files? If I looked at your source code I would assume the header file is
an implementation specific header file for a certain compiler. It would
not immediately occur to me that it was a project header file. When I see
#include "file.h" I immediately think this is a file created by the
project programmer and not the compiler company. This is all jut
convention but having conventions makes it easier for you to work with
others.

--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}


这篇关于标题包含风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆