[问] extern在函数定义面前? [英] [Q]extern in front of function definition?
问题描述
BSD代码在hsearch.c中有以下hcreate函数定义
在lib / libc / db / hash / hsearch.c下。 br />
这里,为什么要使用''extern'?它的目的是什么?为什么在函数定义的前面?
? (通常''extern''放在
函数声明前面....)
extern int
hcreate (nel)
size_t nel;
{
HASHINFO信息;
info.nelem = nel;
info.bsize = 256;
info.ffactor = 8;
info.cachesize = 0;
info.hash = NULL;
info.lorder = 0;
dbp =(DB *)__ hash_open(NULL,O_CREAT | O_RDWR,0600,& info, 0);
返回(dbp!= NULL);
}
....
Hi,
BSD code has following hcreate function definition in hsearch.c
under lib/libc/db/hash/hsearch.c.
Here, why is ''extern'' used ? What''s the purpose of it? How come
in infront of functions definition ? ( Usually ''extern'' is placed in
front of function declaration....)
extern int
hcreate(nel)
size_t nel;
{
HASHINFO info;
info.nelem = nel;
info.bsize = 256;
info.ffactor = 8;
info.cachesize = 0;
info.hash = NULL;
info.lorder = 0;
dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
return (dbp != NULL);
}
....
推荐答案
dj****@gmail.com 说:
BSD代码在hsearch.c中有以下hcreate函数定义
在lib /下libc / db / hash / hsearch.c。
这里,为什么使用''extern'?
Hi,
BSD code has following hcreate function definition in hsearch.c
under lib/libc/db/hash/hsearch.c.
Here, why is ''extern'' used ?
没有真正的理由。
No real reason.
它的目的是什么?
What''s the purpose of it?
我想是有人喜欢打字。
Someone liked typing, I guess.
怎么来
in面前的功能定义?
How come
in infront of functions definition ?
这意味着该函数具有外部链接(无论如何它都具有默认的
)。
It means that the function has external linkage (which it has anyway by
default).
(通常''extern''放在
函数声明前面....)
( Usually ''extern'' is placed in
front of function declaration....)
定义也是声明。
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名中, - www。
Definitions are also declarations.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Richard Heathfield< r ... @ see.sig .invalidwrote:
Richard Heathfield <r...@see.sig.invalidwrote:
djh ... @ gmail.com说:
djh...@gmail.com said:
BSD代码有以下hcreate hsearch.c中的函数定义
在lib / libc / db / hash / hsearch.c下。
这里,为什么使用''extern'?
BSD code has following hcreate function definition in hsearch.c
under lib/libc/db/hash/hsearch.c.
Here, why is ''extern'' used ?
没有真正的理由。
No real reason.
它的目的是什么?
What''s the purpose of it?
有人喜欢打字,我猜。
Someone liked typing, I guess.
我记得clc的一个小组坚持要多余地初始化
_all_自动变量。有些人有奇怪的想法
什么是真实的...... ;-)
-
彼得
I recall one chap on clc insists on redundantly initialising
_all_ automatic variables. Some people have strange notions of
what''s real... ;-)
--
Peter
Peter Nilsson说:
Peter Nilsson said:
Richard Heathfield< r ... @ see.sig。 invalidwrote:
Richard Heathfield <r...@see.sig.invalidwrote:
> djh ... @ gmail.com说:
>djh...@gmail.com said:
BSD code has following在hsearch.c中创建函数定义
在lib / libc / db / hash / hsearch.c下。
这里,为什么使用''extern'?
BSD code has following hcreate function definition in hsearch.c
under lib/libc/db/hash/hsearch.c.
Here, why is ''extern'' used ?
没有真正的理由。
No real reason.
它的目的是什么?
What''s the purpose of it?
有人喜欢打字,我想。
Someone liked typing, I guess.
我记得clc的一个小组坚持要多余地初始化
_all_自动变量。有些人有奇怪的想法
什么是真实的...... ;-)
I recall one chap on clc insists on redundantly initialising
_all_ automatic variables. Some people have strange notions of
what''s real... ;-)
< grinWell,我有我的理由,他们在这里很有名。你能否b / b
想出一个合理的外部资格认证理由?
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名中, - www。
<grinWell, I have my reasons, and they are well known here. Can you
come up with a plausible reason for extern-qualifying functions?
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
这篇关于[问] extern在函数定义面前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!