前ansi声明 [英] pre-ansi declarations
问题描述
标准命令中哪些部分'foo''在下面确定
不符合包含原型的功能:
void foo( a)
char * a;
{
do_something(a);
}
int main(无效)
{
foo();
返回0;
}
,在c99的6.11.2下,如何用内部链接声明文件范围对象怎么可能
不使用''静态''?
-
j0mbolar
Which sections in the standard mandate that ''foo'' below does
not qualify as a function that includes a prototype:
void foo(a)
char *a;
{
do_something(a);
}
int main(void)
{
foo();
return 0;
}
also, under 6.11.2 of c99, how is it possible
to declare a file scope object with internal linkage
without using ''static''?
--
j0mbolar
推荐答案
" j0mbolar" < J0 ****** @ engineer.com>写道:
"j0mbolar" <j0******@engineer.com> writes:
标准命令中哪些部分'foo''不符合包含原型的功能:
void foo(a )
char * a;
{
do_something(a);
}
int main(无效)
{
foo();
返回0;
}
可能是函数原型的定义在6.2.1p2中:
_function prototype_是函数的声明,
声明其参数的类型。
foo()的* definition *声明了a的类型; *声明*
也没有。
,在c99的6.11.2之下,怎么可能用内部声明文件范围对象?联系
不使用''静态''?
Which sections in the standard mandate that ''foo'' below does
not qualify as a function that includes a prototype:
void foo(a)
char *a;
{
do_something(a);
}
int main(void)
{
foo();
return 0;
}
Probably the definition of "function prototype" in 6.2.1p2:
A _function prototype_ is a declaration of a function that
declares the types of its parameters.
The *definition* of foo() declares the type of a; the *declaration*
doesn''t.
also, under 6.11.2 of c99, how is it possible
to declare a file scope object with internal linkage
without using ''static''?
我不知道。还有其他人吗?
-
Keith Thompson(The_Other_Keith) ks ** *@mib.org < http://www.ghoti.net/~kst>
圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
I don''t know. Anybody else?
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Keith Thompson写道:
Keith Thompson wrote:
" j0mbolar" < J0 ****** @ engineer.com>写道:
"j0mbolar" <j0******@engineer.com> writes:
标准命令中哪些部分'foo''不符合包含原型的功能:
void foo(a )
char * a;
{
do_something(a);
}
int main(无效)
{
foo();
返回0;
}
Which sections in the standard mandate that ''foo'' below does
not qualify as a function that includes a prototype:
void foo(a)
char *a;
{
do_something(a);
}
int main(void)
{
foo();
return 0;
}
可能是函数原型的定义。在6.2.1p2中:
一个_function prototype_是一个函数的声明,它声明了它的参数类型。
foo(*的*定义*声明a的类型; *声明*
没有。
Probably the definition of "function prototype" in 6.2.1p2:
A _function prototype_ is a declaration of a function that
declares the types of its parameters.
The *definition* of foo() declares the type of a; the *declaration*
doesn''t.
因此默认参数促销不适用,
做pre-ansi编译器推断出上面例子中的类型
来自''a'',这样他们就知道它是''指向char'的指针'?
-
j0mbolar
So where default argument promotions do not apply,
do pre-ansi compilers infer the type in the above example
from ''a'', so that they know it is a ''pointer to char''?
--
j0mbolar
" j0mbolar" < J0 ****** @ engineer.com>写道:
"j0mbolar" <j0******@engineer.com> writes:
Keith Thompson写道:
Keith Thompson wrote:
" j0mbolar" < J0 ****** @ engineer.com>写道:
"j0mbolar" <j0******@engineer.com> writes:
>标准要求中哪些部分foo在下面的内容中
>不符合包含原型的功能:
>
> void foo(a)
> char * a;
> {
> do_something(a);
> }
>
> int main(void)
> {
> foo();
>返回0;
> }
> Which sections in the standard mandate that ''foo'' below does
> not qualify as a function that includes a prototype:
>
> void foo(a)
> char *a;
> {
> do_something(a);
> }
>
> int main(void)
> {
> foo();
> return 0;
> }
可能是函数原型的定义。在6.2.1p2中:
一个_function prototype_是一个函数的声明,它声明了它的参数类型。
foo(*的*定义*声明a的类型; *声明*
没有。
Probably the definition of "function prototype" in 6.2.1p2:
A _function prototype_ is a declaration of a function that
declares the types of its parameters.
The *definition* of foo() declares the type of a; the *declaration*
doesn''t.
因此,默认参数促销不适用,
做pre-ansi编译器推断上面示例中的类型
来自''a'',以便他们知道它是''指向char的指针''?
So where default argument promotions do not apply,
do pre-ansi compilers infer the type in the above example
from ''a'', so that they know it is a ''pointer to char''?
在函数中,声明一个是可见的,所以编译器
知道它是一个char *。
对于一个调用,编译器不知道什么类型的参数
函数需要,因此调用者可以通过正确的类型。
它与类似printf的函数类似。 />
-
Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst>
圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
Within the function, the declaration of a is visible, so the compiler
knows it''s a char*.
For a call, the compiler doesn''t know what type of argument the
function expects, so it''s up to the caller to pass the right type.
It''s similar to what happens with printf-like functions.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
这篇关于前ansi声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!