📄 static.jd.html
字号:
<html><!-- Mirrored from c-faq.com/decl/static.jd.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 08:02:57 GMT --><head><title></title></head><body>From: Jutta Degener<br>Newsgroups: comp.lang.c<br>Subject: Re: static declarations of functions<br>Date: 5 Oct 1993 09:09:10 GMT<br>Message-ID: <28rdjm$74r@news.cs.tu-berlin.de><p>Jos Horsmeier writes:<br>>In article <....> Larry Jones writes:<br>>|In article <....>, David Alan Boles writes:<br>>|> <TT>static void dummy(int, int, int *);</TT><br>>|> <TT>void dummy(int a, int b, int *c) { *c = a + b; }</TT><br>>|> <br>>|> Looking at Steele's book, it seems to say that the word <TT>static</TT> must<br>>|> be present in both places, but it is not clear on this. [...]<br>>|<br>>|It says you have to have <TT>static</TT> in both places. [...]<br>><br>> No, if the first declaration declares the object to be a static object<br>> (no external linkage), following declarations (and the definition) can<br>> omit the `static' keyword. The other way around would result in a<br>> compiler warning though ...<br><p>Jos Horsmeier has started talking about objects now where Larry Jonesand David Alan Boles were discussing functions. Unfortunately, functionand object linkages are treated differently.<p>The rules that Larry thought apply to functions apply to objects,while the rules that Jos states for objects apply to functions.<p>Example:<p><pre>/* object */ /* function */int o1; int f1(); /* external linkage */static int o2; static int f2(); /* internal linkage */static int o3; static int f3(); /* internal linkage */static int o1; static int f1(); /* ERROR, both have external linkage */int o2; /* ERROR, o2 has internal linkage */ int f2(); /* OK, picks up internal linkage */extern int o3; extern int f3(); /* OK, both pick up internal linkage */</pre><p>The difference is case (2); where functions do pick up a previouslinkage even without "extern", objects don't.<p>Jutta Degener</body><!-- Mirrored from c-faq.com/decl/static.jd.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 08:02:57 GMT --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -