Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
What exactly this thing do? It is a preprocessor?

The code with that element is:
typedef int intptr;
typedef long intptr;
typedef long long intptr;
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)

#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
compiler writes the error C1189 (Visual Studio 2008). Can you help me with it?

Edit - moved information from OP here
Updated 22-May-12 4:59am
lewax00 22-May-12 11:00am    
You can add additional information by clicking "Improve question", it shouldn't be added a a solution (where it may not be seen)

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?
Share this answer
Je7 22-May-12 11:13am    
It is code from TrinityCore sources I should to look all the commits to the core(I have private core) and maybe will found the solution.
lewax00 22-May-12 11:20am    
Looks like this person was having the same problem and fixed it:
Je7 22-May-12 11:28am    
This error as a result of my inattention. Thx for solution.

P.S.: I am for the first time on your site, it's very helpful.
Aescleal 22-May-12 11:38am    
Alas the assumption was for years that a pointer and int were the same size. However this isn't the case any more - most compiler vendors have decided that there's no point in having a default 64 bit int.

Luckily I gave up casting pointers to ints ages ago.
lewax00 22-May-12 11:53am    
Well in any case int generally isn't smaller than a pointer, so it should be int, long, or long long. But I agree, casting seems unnecessary (if you really need a generic pointer form, void* already exists, though C++ should be utilizing templates instead).
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.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900