本文介绍了从void **转换为char **有多危险的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我们知道标准不会强制指针大小相等. (此处此处)(而非谈论函数指针)

So we know that the standard doesn't force pointer sizes to be equal. (here and here) (and not talking about function pointers)

我想知道实际上这可能是个问题.我们知道void *可以容纳任何内容,因此如果指针大小不同,那将是最大大小.鉴于此,将void **分配给char **意味着麻烦.

I was wondering how in reality that can be an issue. We know that void * can hold anything, so if the pointer sizes are different, that would be the biggest size. Given that, assigning a void ** to a char ** means trouble.

我的问题是,假设void *char *具有相同的大小将有多危险?真的有一个不正确的架构吗?

My question is how dangerous would it be to assume void * and char * have the same size? Is there actually an architecture where this is not true?

此外,我不希望听到16位dos信息! ;)

Also, 16-bit dos is not what I want to hear! ;)

推荐答案

void *char *保证具有相同的大小.

void * and char * are guaranteed to have the same size.

void **不能保证具有与char **相同的大小(但是在实现上非常有可能).

void ** is not guaranteed to have the same size as char ** (but very likey on your implementation they will).

这篇关于从void **转换为char **有多危险的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 04:58