该问题没有为答案提供足够的信息。给定的 答案根本没有意义。它是什么书?如果它说出你说的话 说,那么你最好得到另一本书。 注意,问题是关于表达式是否允许 或编译器不允许,换句话说,表达式是否为b $ b b格式良好或格式错误。为了回答这个问题,我们需要知道p和c的类型。例如,如果''p''的类型为''void *'',则将''++''运算符应用于它是非法的 ,编译器将禁止它。如果''p''是类型''double *''和''c''类型为''struct Foo'',那么我们就完全没有了分配中不相关的类型,这也将导致来自 编译器的诊断。等等。没有这些额外的信息,就没有办法说b / b $ b $是否有必要让编译器抱怨的东西。 另一方面,建议的答案似乎解决了众所周知的违反对象访问和序列点规则的问题(不知道更好的名字) for it)。即使在某些代码中违反了这个规则,它也不会使代码形成错误,即编译器不需要诊断。它不会是不允许b $ b不允许由编译器即使存在问题。相反,代码 将产生未定义的行为。还有很多其他的方法,顺便说一下,上面的表达式如何产生未定义的行为。但这是无关紧要的,因为它&b 与被编译器禁止无关。 - 祝你好运, Andrey TarasevichThe question does not provide enough information for an answer. And the givenanswer does not make sense at all. What book is it? If it says what you say itsays, then you better get another book.Note, that the question is specifically about whether the expression is allowedor disallowed by the compiler or, in other words, whether the expression iswell-formed or ill-formed. In order to answer the question we need to know thetypes of ''p'' and ''c''. For example, if ''p'' is of type ''void*'', then it is illegalto apply the ''++'' operator to it and the compiler will disallow it. If ''p'' is oftype ''double*'' and ''c'' is of type ''struct Foo'', then we have completelyunrelated types in assignment, which will also cause a diagnostic from thecompiler. And so on. Without having this extra information, there''s no way tosay whether there''s something there that must cause the compiler to complain.The proposed answer, on the other hand, seems to address the well-known issue ofviolating the object-access-and-sequence-points rule (don''t know a better namefor it). Even if this rule is violated in some code, it does not make the codeill-formed, i.e. no diagnostic is required from the compiler. It won''t be"disallowed" by the compiler even if there''s a problem there. Instead, the codewill produce undefined behavior. There many are other ways, BTW, how the aboveexpression might produce undefined behavior. But this is irrelevant, since ithas nothing to do with being "disallowed by the compiler".--Best regards,Andrey Tarasevich 我认为这是一个错字: * p ++ = p; 这意味着: 取p指向的对象,并存储值p。在里面。然后 增量p。很像: * p = p; ++ p; 其中,在完整的上下文中,必须是这样的: int main() { void * ptr [2] = 0; void ** p = ptr; * p ++ = p; } - Frederick GothamI presume that that''s a typo for:*p++ = p;Which means:Take the object pointed at by "p", and store the value "p" in it. Thenincrement "p". Quite like:*p = p;++p;Which, in full context, would have to be something like:int main(){void *ptr[2] = 0;void **p = ptr;*p++ = p;}--Frederick Gotham 这篇关于编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-03 19:26