enum type mixed with another type

I'm getting a warning "enumeration type mixed with another type" with the following line of code.

typedef enum { FALSE = 0, TRUE  = !FALSE } bool;

bool bResult;
bool bAAA;
bool bBBB;

bResult = bAAA && bBBB;  // <-- warning

bResult = (bAAA == TRUE) && (bBBB == TRUE); // <-- same results

Any suggestions?

Parents
  • I just reviewed ritchie & kernie. Section A7.14: "The && operator groups left-to-right. It returns 1 if both its operands compare unequal to zero, 0 otherwise."

    The logic operation is returning a 1 or 0 and its being assigned to a bool (defined by the enum). If I perform the following, the warning is removed:

    bResult = (bAAA && bBBB) ? TRUE : FALSE;
    


    Since I'm including STR 73x_type.h in my code (located in my common project space), I made the following changes.

    #ifdef __PROJECT__
    typedef u16 bool;
    #define FALSE 0
    #define TRUE 1
    #else
    typedef enum { FALSE = 0, TRUE != FALSE } bool;
    #endif
    


    Compiles without the warning and my code should now be safer with this convension. __PROJECT__ is defined in the project file.

    Thanks

Reply
  • I just reviewed ritchie & kernie. Section A7.14: "The && operator groups left-to-right. It returns 1 if both its operands compare unequal to zero, 0 otherwise."

    The logic operation is returning a 1 or 0 and its being assigned to a bool (defined by the enum). If I perform the following, the warning is removed:

    bResult = (bAAA && bBBB) ? TRUE : FALSE;
    


    Since I'm including STR 73x_type.h in my code (located in my common project space), I made the following changes.

    #ifdef __PROJECT__
    typedef u16 bool;
    #define FALSE 0
    #define TRUE 1
    #else
    typedef enum { FALSE = 0, TRUE != FALSE } bool;
    #endif
    


    Compiles without the warning and my code should now be safer with this convension. __PROJECT__ is defined in the project file.

    Thanks

Children
More questions in this forum