加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 为什么char **(或任何T **)无效**转换无效?

发布时间:2020-12-16 10:35:37 所属栏目:百科 来源:网络整理
导读:在 Python C Module – Malloc fails in specific version of Python的第一条评论中,@ user694733提到将char **转换为void **无效.我读过 Invalid conversion from Foo** to void** – why is implicit type conversion allowed to void* but not to void**?
在 Python C Module – Malloc fails in specific version of Python的第一条评论中,@ user694733提到将char **转换为void **无效.我读过 Invalid conversion from Foo** to void** – why is implicit type conversion allowed to void* but not to void**?和 http://c-faq.com/ptrs/genericpp.html,但有一个标准的引用,但没有真实的例子,在这种情况下,这可能是不正确的,导致错误.考虑例如void **加倍**或反之亦然,是否有可能出错的情况?为什么(从技术上讲,不仅仅因为它是UB)?

解决方法

but there is a reference to standard,but no real example,in which case this might be incorrect,leading to errors

这不准确.您提到的页面http://c-faq.com/ptrs/genericpp.html指向另一个页面http://c-faq.com/null/machexamp.html,其中包含不同类型的指针大小不同的计算机示例:

The Eclipse MV series from Data General has three architecturally supported pointer formats (word,byte,and bit pointers),two of which are used by C compilers: byte pointers for char * and void *,and word pointers for everything else. For historical reasons during the evolution of the 32-bit MV line from the 16-bit Nova line,word pointers and byte pointers had the offset,indirection,and ring protection bits in different places in the word. Passing a mismatched pointer format to a function resulted in protection faults. Eventually,the MV C compiler added many compatibility options to try to deal with code that had pointer type mismatch errors.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读