解释结果

编程入门 行业动态 更新时间:2024-10-19 06:19:25
本文介绍了解释结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 帮我理解程序: func() { } main() { fprintf(stderr," sizeof(func):%d \ n" ;,sizeof(func)); } 输出:sizeof(func):1 我以为它会返回4个字节。因为func是一个符号, 指向函数的相对地址。但它返回1 字节。请帮我理解这个程序。 谢谢 Param

Hi Help me to understand the program: func() { } main() { fprintf(stderr, "sizeof(func):%d\n", sizeof(func)); } output: sizeof(func):1 I thought that it would return 4 bytes. since func is a symbol which is pointing to the relative address of the function. But it returns 1 byte. Please help me to understand the program. Thanks Param

推荐答案

param写道: param wrote: 嗨 帮我理解程序: func() { } main() { fprintf(stderr," sizeof(func):%d \ n",sizeof(func)); } 输出:sizeof(func):1 我以为它会返回4个字节。因为func是一个符号, 指向函数的相对地址。但它返回1 字节。请帮我理解这个程序。 Hi Help me to understand the program: func() { } main() { fprintf(stderr, "sizeof(func):%d\n", sizeof(func)); } output: sizeof(func):1 I thought that it would return 4 bytes. since func is a symbol which is pointing to the relative address of the function. But it returns 1 byte. Please help me to understand the program.

好​​吧,我很惊讶你设法得到这个编译。是stderr 在您的实现上自动定义(在这种情况下它是否会损坏),或者您是否只是在编译时没有复制确切的代码? 也就是说,你不能将sizeof应用于函数类型。如果你无论如何都要支付,并且编译器接受它,那么无法保证将会发生什么事情。

Well, I''m surprised you managed to get this compiled at all. Is stderr automatically defined on your implementation (in which case it''s broken), or did you just not copy the exact code as you compiled it? That said, you can''t apply sizeof to a function type. If you do anyway, and the compiler accepts it, there''s no guarantee whatsoever about what''ll happen.

" Harald van D?k" < tr ***** @ gmail写信息 news:11 ********************** @ l77g2000hsb。 googlegr oups ... "Harald van D?k" <tr*****@gmailwrote in message news:11**********************@l77g2000hsb.googlegr oups... >我认为它会返回4个字节。因为func是一个符号,它指向函数的相对地址。但它返回1 字节。请帮我理解这个程序。 >I thought that it would return 4 bytes. since func is a symbol whichis pointing to the relative address of the function. But it returns 1byte. Please help me to understand the program.

嗯,我很惊讶你设法得到这个编译。是stderr 在你的实现上自动定义了(在这种情况下它被打破了b $ b),还是你在编译时没有复制确切的代码?

Well, I''m surprised you managed to get this compiled at all. Is stderr automatically defined on your implementation (in which case it''s broken), or did you just not copy the exact code as you compiled it?

破碎是一个有点强烈的单词imo,如果编译器有标准库名称的知识,它似乎不是很糟糕,尽管我这样做明白它确实这样做。可以编写不适用于其他抱怨编译器的代码。

broken is a bit strong word imo, it doesnt seems so bad if a compiler has knowledge of standard library names, although i do understand that it does make it possible to write code that wont work on other complaiant compilers.

3月25日下午3:02, " PARAM" < sparamesw ... @ gmailwrote: On Mar 25, 3:02 pm, "param" <sparamesw...@gmailwrote: 帮我理解程序: func() { } main() { fprintf (stderr,sizeof(func):%d \ n,sizeof(func)); } 输出: sizeof(func):1 我以为它会返回4个字节。因为func是一个符号, 指向函数的相对地址。但它返回1 字节。请帮我理解这个程序。 Help me to understand the program: func() { } main() { fprintf(stderr, "sizeof(func):%d\n", sizeof(func)); } output: sizeof(func):1 I thought that it would return 4 bytes. since func is a symbol which is pointing to the relative address of the function. But it returns 1 byte. Please help me to understand the program.

func不是函数指针。考虑: [tmp]

func is not a function pointer. Consider: [tmp]

更多推荐

解释结果

本文发布于:2023-10-26 18:45:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531028.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!