Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
warning C6326: potential comparison of a constant with another constant
This warning indicates a potential comparison of a constant with another constant, which is redundant code. You must check to make sure that your intent is properly captured in the code. In some cases, you can simplify the test condition to achieve the same result.
Example
The following code generates this warning because two constants are compared:
#define LEVEL
const int STD_LEVEL = 5;
const int value =
#ifdef LEVEL
10;
#else
5;
#endif
void f()
{
if( value > STD_LEVEL)
{
// code...
}
else
{
// code...
}
}
The following code shows one method of correcting this warning by using the #ifdef statements to determine which code should execute:
#define LEVEL
const int STD_LEVEL = 5;
const int value =
#ifdef LEVEL
10;
#else
5;
#endif
void f ()
{
#ifdef LEVEL
{
// code...
}
#else
{
// code...
}
#endif
}