Hi
Might be a really simple question with an even simpler answer, however I can't get rid if the following warnings in Visual C++ 6.0 (SP5):
quote:
--------------------Konfiguration: ILG - Win32 Release--------------------
Kompilierung läuft...
loadsettings.cpp
I:\ILG\loadsettings.cpp(37) : warning C4800: 'int' : Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten moeglich)
I:\ILG\loadsettings.cpp(38) : warning C4800: 'int' : Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten moeglich)
I:\ILG\loadsettings.cpp(39) : warning C4800: 'int' : Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten moeglich)
I:\ILG\loadsettings.cpp(40) : warning C4800: 'int' : Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten moeglich)
Linker-Vorgang läuft...
ILG.exe - 0 Fehler, 4 Warnung(en)
which translates to something like that:
quote:
--------------------Configuration: ILG - Win32 Release--------------------
Compilation running...
loadsettings.cpp
I:\ILG\loadsettings.cpp(37) : warning C4800: 'int' : variable is being set to boolean value ('True' or 'False') (may effect performance)
I:\ILG\loadsettings.cpp(38) : warning C4800: 'int' : variable is being set to boolean value ('True' or 'False') (may effect performance)
I:\ILG\loadsettings.cpp(39) : warning C4800: 'int' : variable is being set to boolean value ('True' or 'False') (may effect performance)
I:\ILG\loadsettings.cpp(40) : warning C4800: 'int' : variable is being set to boolean value ('True' or 'False') (may effect performance)
Linker-procedure running...
ILG.exe - 0 Errors, 4 Warning(s)
This is the troublesome code:
Settings->General.nDevice = pnData[0];
Settings->General.bFullscreen = static_cast<bool>(pnData[1] & GF_FullScreen);
Settings->General.bHALTransform = static_cast<bool>(pnData[1] & GF_HALTrans);
Settings->General.bVSync = static_cast<bool>(pnData[1] & GF_VSync);
Settings->General.bNoVSync = static_cast<bool>(pnData[1] & GF_NoVSync);
Settings->General.bMultitexture = static_cast<bool>(pnData[1] & GF_Multitex);
Settings->General.nWidth = pnData[2];
Settings->General.nHeight = pnData[3];
Settings->General.nBitDepth = pnData[4];
|
It's the bottom four of the five lines with the static_cast. It doesn't matter if I use the cast or not, it always gives me the warning.
pnData is a pointer to an int array, the GF_ constants are part of this enum:
enum Const_GeneralFlags
{
GF_FullScreen = 1,
GF_VSync = 2,
GF_NoVSync = 4,
GF_DefaultVSync = 0,
GF_Multitex = 8,
GF_HALTrans = 16
};
|
Obviously, it likes the first of the five lines because it only can return 0 or 1. Can I somehow solve this without bitshifting or so?
(e.g.
(pnData[1] & GF_HALTrans) << 4
) Using that solution would generally reduce readability.
Thanks in advance.
-
JQ
Infiltration: Losing Ground
"Simpson, eh?" -Mr. Burns
"Excellent!" -the above
Edited by - JonnyQuest on July 13, 2001 9:27:14 AM