#error sizeof(void *)既不是sizeof(int)也不是sizeof(long)也不是sizeof(long long) [英] #error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)

查看:132
本文介绍了#error sizeof(void *)既不是sizeof(int)也不是sizeof(long)也不是sizeof(long long)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这东西到底是做什么的?它是预处理器吗?

具有该元素的代码是:

What exactly this thing do? It is a preprocessor?

The code with that element is:

#if SIZEOF_CHARP == SIZEOF_INT
typedef int intptr;
#elif SIZEOF_CHARP == SIZEOF_LONG
typedef long intptr;
#elif SIZEOF_CHARP == SIZEOF_LONG_LONG
typedef long long intptr;
#else
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
#endif





on

#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)

编译器将写入错误C1189(Visual Studio 2008).你能帮我吗?

编辑-从OP中移出的信息在这里

compiler writes the error C1189 (Visual Studio 2008). Can you help me with it?

Edit - moved information from OP here

推荐答案

它是由编译器生成的. sizeof(void *)取决于要编译的系统.例如,如果您为32位Windows XP或32位Linux XP进行编译,则由于内存地址的大小为32位(4字节),因此sizeof(void *)将为4.
如果针对Windows XP 64位或Windows Vista 64位或Windows 7 64位或Linux 64位进行编译,则内存地址的大小将为64位(8字节),而sizeof(void *)将为8.sizeof(int )将为4(32位).

PS:指针是存储内存地址的变量.
It is generated by the compiler. sizeof(void*) depends for which system you are compiling. For example, if you compile for Window XP 32 bit or Linux 32 bit, sizeof(void*) will be 4 because the size of a memory address is 32 bits (4 bytes).
If you compile for Windows XP 64 bit or Windows Vista 64 bit or Windows 7 64 bit or Linux 64 bit, the size of a memory address will be 64 bits (8 bytes) and sizeof(void*) will be 8. sizeof(int) will be 4 (32 bits).

PS: A pointer is a variable which stores a memory address.


其目的是引发错误(请参见 ^ ]).尽管查看其中的部分,但我发现奇怪的是,除非将SIZEOF_CHARP,SIZEOF_INT,SIZEOF_LONG或SIZEOF_LONG_LONG设置不正确,否则应将其全部抛出.据我所知,int几乎总是与系统指针相同.

我从您的问题中猜测您没有编写该代码,它是从哪里来的?
Its purpose is to throw an error (see this page[^]). Although, looking at the section it''s in, I find it odd that it should be thrown at all unless SIZEOF_CHARP, SIZEOF_INT, SIZEOF_LONG, or SIZEOF_LONG_LONG are set incorrectly. To my knowledge, int is almost always the same size as a pointer for the system.

I''m guessing from your question you didn''t write that code, where did it come from?


这篇关于#error sizeof(void *)既不是sizeof(int)也不是sizeof(long)也不是sizeof(long long)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆