Quote:Original post by likeafox
If I were to write something like this it would compile and work just fine: char * var1 = "Hello";
So why can't I do something like this?:__int32 * var2 = &(const_cast<__int32>(0x02i32));
The first case is different from the second case. "Hello" is an array, which converts to a pointer automatically. It's as simple as that. BTW, some compilers don't generate an error due to const mismatch in the first case because of the all the code that would no longer compile.
Your error is due to using const_cast incorrectly. This code:
__int32 * var2 = &(0x02i32);
generates this error in VS 2005:
error C2101: '&' on constant
Quote:Original post by likeafox
Does anyone know how to get the address of an inline constant?
Considering that it is not stored in memory, how could it have an address?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!