" jacob navia" < JA *** @ jacob.remcomp.fr>在消息中写道 news:bq ********** @ news-reader4.wanadoo.fr ..."jacob navia" <ja***@jacob.remcomp.fr> wrote in messagenews:bq**********@news-reader4.wanadoo.fr... xarax ; < xa的*** @ email.com>在消息中写道新闻:78 ******************* @ newsread2.news.pas.eart hlink.net ... "xarax" <xa***@email.com> wrote in message news:78*******************@newsread2.news.pas.eart hlink.net...以上所有都是特定于实现的,因此OFF TOPIC。不需要堆或堆栈框架,因为我们知道并喜欢它们。实现被允许做他们想要的任何事情,好像行为似乎符合标准。 抱歉,我从标准中收集到由局部变量分配的存储是仅在执行函数期间有效。 由于函数返回并被调用,这意味着堆栈结构 All of the above is implementation specific and therefore OFF TOPIC. There is no requirement for a heap or stackframe as we know and love them. Implementations are allowed to do whatever they want as if the behavior appears to conform to the standard. Sorry but I gather from the standard that the storage allocated by local variables is valid only during the execution of a function. Since functions return and are called, this implies a stack structure .... can使用,但不是必须的。 单向或反向。 或者可以使用其他一些非堆栈方法。 这个东西从main()开始,可以调用其他函数。 不需要函数调用函数的功能 用栈实现。 只要程序运行,全局范围就是无限期的。 这是肯定的。程序执行的持续时间。 这意味着C肯定会假设这个存储在概念上与本地存储区别不同。 " Local" vs非本地这不是一生的问题,而是范围问题。 但是,本地与全球范围被视为截然不同。 那是''毕竟,范围意味着什么。 :-) 但是并没有要求编译器在内部存储例如所有全局变量和所有本地变量的'b $ b'''。这通常是完成的, 但这是一个实现细节。 malloc / free是标准的一部分。 是的。你的观点是什么?.... can be used, but not that one is required. one way or the other.Or some other non-stack method may be used.The thing gets started with main() that can call other functions.The ability for functions to call functions is not requiredto be implemented with a stack. The scope of a global is indefinite, as long as the program runs.It is definite. The duration of the program''s execution. This means that C surely assumes that this storage is distinct conceptually from the local storage."Local" vs "nonlocal" is not a lifetime issue, but one of scope.But yes, ''local'' vs. ''global'' scopes are considered distinct.That''s what ''scope'' means, after all. :-)But there''s no requirement that a compiler internally store e.g''all globals here and all locals there''. This is often done,but this is an implementation detail. malloc/free are part of the standard.Yes they are. What''s your point?指向有效内存位置的指针可以来自外部源(例如,由当前正在运行的代理生成) C程序),并且可以被当前运行的C程序使用。 是的,我们可以假设操作系统返回应用程序的有效指针,但这种情况非常罕见, Pointers to valid memory locations can come from an external source (e.g., generated by an agent other than the currently running C program), and be usable by the currently running C program. Yes, we could hypothetically assume that the operating system returns valid pointers to applications but this is very uncommon, 我觉得很常见。例如。 Microsoft Windows非常广泛。具有接口的嵌入式设备也是如此。 在明显的malloc / free调用之外。 这是非常罕见的,可以是安全地忘记了。 IMO并不罕见。 另外,根据我的经验,罕见的问题是最困难的。 > 来纠正(甚至定位)。I find it very common. E.g. Microsoft Windows is verywidespread. So are embedded devices with interfaces thatuse pointers. outside the obvious call to malloc/free. This is very rare and can be safely forgotten.IMO not rare at all.Also, in my experience, the ''rare'' problems are the most difficultto rectify (or even locate).你的前提是有缺陷的,因此你的结论毫无意义。 这里没有任何瑕疵。 Your premise is flawed, therefore your conclusions are meaningless. There is nothing flawed here.有很多内存管理工具可以替代malloc()和朋友的常见实现,用于查找堆损坏,悬空引用等等。 There are plenty of memory management tools out there that are replacements for the common implementations of malloc() and friends, for locating heap corruption, dangling references, etc. 它们可能与我所描述的非常类似。 And they do probably a very similar thing to what I described. 必须以特定于平台的方式。In necessarily platform specific ways.这完全依赖于实现细节,而且需要编译器对堆实现有深入的了解。是的。那么呢? It is all dependent upon implementation details and is something that would require a compiler to have intimate knowledge of the heap implementation. Yes. And so what? 所以在这里,我们讨论标准C,而不是实现细节。 我的问题是:添加它会很有趣吗语言本身? 也许对某些人来说可能是这样,但对其他人来说却不行。 C因为充足的机会而受到广泛的批评,并且有理由指针错误。 C语言没有必要证明它存在于任何 评论家。我认为它取决于它自己的成功。 AFAIK, 除了COBOL,它是最古老的高级语言,但仍然广泛使用(我欢迎来自历史学家的任何更正)。 想到这个并不是主题。 实际上是。在这里我们讨论C语言。 它是开发过程中任何程序中最常见错误之一。 是的。这就是为什么许多/大多数''评论家''你引用了b $ b b经常试图将他们的工具归咎于他们的错误。 C语言的两个概念构成了我们差异的基础。对你来说,对语言的一些基本原则的任何反思都是非主题。 关于C的基本原则的解释,作为帮助某人的一部分 与C确实是热门话题。关于 ''如何以及为什么',''可以/应该有所不同'等等的推测/建议不是。 我我认为关于我们如何改进事情的讨论太少了。So here, we discuss standard C, not implementation details. My question is: would it be interesting to add to the language itself?Perhaps it might be to some, but not to others. C has been widely critized, and with reason, for the ample opportunities of pointer errors.The C language has no need to justify its existence to anycritics. I think it stands upon its own success. AFAIK,besides COBOL, it''s the oldest high-level language still inwidespread use (I welcome any corrections from the historians).Giving thought to this is not off topic here.Actually it is. Here we discuss the C language as it is.It is one of the most common errors in any program when it is being developed.Yes it is. Which is why many/most of the ''critics'' you citeoften try to blame their tools for their mistakes. Two conceptions of the C language underlie our differences. For you, any reflection about some basic tenets of the language is "off topic".Explanations of ''basic tenets'' of C as part of helping someonewith C are indeed topical. Speculations/suggestions about the''how and why'', ''can/should something be different'', etc. are not. I think too little discussion is going on about how we could improve things. 很多这样的讨论正在发生,你只是显然没有&br / > 意识到这一点。许多此类讨论的结果是C99。 十多年的讨论。太少了? :-) 我建议你访问comp.std.c如果你想分享想法 关于语言的变化。 -MikeMuch such discussion is occurring, you just apparently aren''taware of it. The result of many such discussions was C99.Ten-plus years of discussion. Too little? :-)I suggest you visit comp.std.c if you want to share ideasabout changes to the language.-Mike 这篇关于指针有效性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!