A tag mismatch warning that I don't understand...
#1

Okay, this makes absolutely no sense to me. I keep getting a tag mismatch on this line:

pawn Код:
if(vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
"VEHICLE_TYPE_FACTION" is defined in an enum and " vType" is in a different enum but it doesn't have a specific tag or anything.

pawn Код:
enum eVehicleType
{
    VEHICLE_TYPE_ZERO_FILL, // bug prevention
    VEHICLE_TYPE_PERSONAL,
    VEHICLE_TYPE_FACTION,
    VEHICLE_TYPE_PUBLIC,
    VEHICLE_TYPE_BUSINESS,
};
However, if I use a switch, the warning goes away:

pawn Код:
switch(vStats[vehicleID][vType])
    {
        case VEHICLE_TYPE_FACTION:
        {
            //
        }
    }
It has nothing to do with the code above, because this has happened to me before with a different enum. I don't understand why it's doing this though. Isn't "VEHICLE_TYPE_FACTION" just being replaced with a number corresponding to the location in the enum?

Why would the switch work, but not the if statement?
Reply
#2

Your vType is probably inside enum declaring strong tag (starting with big letter). Like:

pawn Код:
enum VehicleInfo {
    vType
    //(...)
}
So, do one of the following:
pawn Код:
if(eVehicleType:vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
//or
if(vStats[vehicleID][vType] == VehicleInfo:VEHICLE_TYPE_FACTION)
//or
if(_:vStats[vehicleID][vType] == _:VEHICLE_TYPE_FACTION)
#e: and the reason why switch isn't causing tag mismatches, is because everything in there is reduced to numeric constants (_ tag), while if checks everything
Reply
#3

Come on RealCop, this is described on the Wiki
Reply
#4

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Your vType is probably inside enum declaring strong tag (starting with big letter). Like:

pawn Код:
enum VehicleInfo {
    vType
    //(...)
}
So, do one of the following:
pawn Код:
if(eVehicleType:vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
//or
if(vStats[vehicleID][vType] == VehicleInfo:VEHICLE_TYPE_FACTION)
//or
if(_:vStats[vehicleID][vType] == _:VEHICLE_TYPE_FACTION)
#e: and the reason why switch isn't causing tag mismatches, is because everything in there is reduced to numeric constants (_ tag), while if checks everything
Nope, it starts with a lowercase e.

pawn Код:
enum enumVehicleData
{
    vID,
    vType,
    vOwnerID,
    vModel,
    vSecurityLevel,
    vMod0,
    vMod1,
    vMod2,
    vMod3,
    vMod4,
    vMod5,
    vMod6,
    vMod7,
    vMod8,
    vMod9,
    vMod10,
    vMod11,
    vMod12,
    Float:vPosX,
    Float:vPosY,
    Float:vPosZ,
    Float:vAngle,
    vKeys,
    vFuel,
    vPaintjob,
    vMileage,
   
    vScriptID,
    bool:vLights,
    bool:vEngine,
    bool:vAlarm,
    bool:vLock,
    bool:vBonnet,
    bool:vBoot,
    Float:vSpeedM,
    Float:vSpeedTh,
    Float:vMaxSpeedTh,
    bool:vBroken
};
@Bakr: Is it really?

#e: Is it bad if I don't name my enums? Because, removing the "name" or the "tag" of the enum seems to remove the tag mismatch warning...
Reply
#5

Do you actually use eVehicleType as an initializer somewhere? If not, you can just remove it. Otherwise, you should prefix vType with the eVehicleType tag.
pawn Код:
enum enumVehicleData {
    eVehicleType:vType
}
Reply
#6

I don't. I went ahead and removed it along with some of my other enum tags. I expected the compiler to tell me I couldn't do that but everything compiled fine and the enum numbers are still the same. I have no idea why we started tagging enums anyways.

Thanks guys- problem solved!

Note to self: I should read the Wiki better.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)