Shrinivas Patgar
Shrinivas Patgar

Reputation: 121

Lint Warning 506: prio3: Constant value Boolean

When i run my code for lint, I am getting warnings saying that "Warning 506: Constant value Boolean" for the line where i am assigning a variable with Macro.

    #define FALSE   (0) 
    #define TRUE    (!FALSE)
    typedef char              BOOL;
    BOOL fTriggerCallback;

    fun_1()
    {
        fTriggerCallback = FALSE; //No warning
    }

    fun_2()
    {
       if(fTriggerCallback == FALSE)
         {
             fTriggerCallback =TRUE; //here is the warning
         }
    }

    fun_3()
    {
        fTriggerCallback =TRUE; //here is the warning
    }

In this code I am getting warnings where I assign TRUE to variable. Warnings are not seen where I assign the FALSE to variable.

But when I changed the Macro #define TRUE 1 the warning is fixed. I dont know the exact cause/reason behind this.

Upvotes: 1

Views: 3464

Answers (1)

thetic
thetic

Reputation: 193

Lint is complaining because TRUE is expanded to (!FALSE) which is expanded to (!0). Error 506 flags:

A Boolean, i.e., a quantity found in a context that requires a Boolean such as an argument to && or || or an if() or while() clause or !, was found to be a constant and hence will evaluate the same way each time.

Lint is complaining about a logical operation (!) on an constant value (0). If C99's stdbool.h is not available, read into PC-lint's strong types.

Upvotes: 2

Related Questions