|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Visual Studio 7
Hi!
Why does this code not work? const int INTSIZE = sizeof(int); //sizeof(int) = 4 #if (INTSIZE!=4) //do something #endif INTSIZE is 0!!! in the #if statment above, why?? |
|
#2
|
|||
|
|||
|
INTSIZE is an integer variable that will only exist when the code is running. #if is a compile time only test. Since INTSIZE has no value at compile time, it will evaluate to zero. If you really want to do a one time capture of sizeof(int) you can try this instead:
#define INTSIZE (sizeof(int)) Then your #if will work. |
|
#3
|
|||
|
|||
|
The "#" is for conditional compilation, so just test with a normal if
if( INT_SIZE !+ 4){ //do stuff } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Visual Studio 7 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|