Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected expression before '!=' token... Where I'm wrong?

Tags:

c

struct

typedef

enum LIVELLI_EMERGENZA {
    LIV_EME_UNO                                 = 0x0001,
    LIV_EME_DUE                                 = 0x0002,
    LIV_EME_TRE                                 = 0x0003
};

typedef struct Emergenza {
    int Tipo;
    short Livello;
} Emergenza;

void TrovaEmergenze()
{
    if(INPUT_GET(IN_FUNGO_EMERGENZA)) {
        Emergenza.Tipo |= EME_FUNGO_PREMUTO;
        Emergenza.Livello |= LIV_EME_UNO;
    }
    if((INPUT_GET(IN_FC_CARTER_LAMA))){
        Emergenza.Tipo |= EME_CARTER_LAMA_APERTO;
        Emergenza.Livello |= LIV_EME_DUE;
    }
}

char EmeLivello1()
{
    if((Emergenza.Livello & LIV_EME_UNO) != 0)
        return 1;
    return 0;
}

Having evaluated the mask emergenza.livello I'm going to check it with & LIV_EME_UNO. If it is different from 0, this means that the bits in the mask is high; but I get the error "expected expression before '!=' token".

like image 245
F.Guerinoni Avatar asked Apr 10 '26 20:04

F.Guerinoni


1 Answers

In your code, Emergenza is essentially a datatype, not a variable. You need to have a variable of that type to use the member access operator .

To make Emergenza a variable instead of a datatype do this:

struct Emergenza {
        int Tipo;
        short Livello;
} Emergenza;

In summary, remove the typedef.

like image 121
Sourav Ghosh Avatar answered Apr 12 '26 08:04

Sourav Ghosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!