Raised This Month: $404 Target: $400
 101% 

Why 'warning 213: tag mismatch enum?'


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rikka0w0
Member
Join Date: May 2018
Location: Sydney, Australia / Beij
Old 10-10-2018 , 11:21   Why 'warning 213: tag mismatch enum?'
Reply With Quote #1

I have the following code:
HTML Code:
enum L4DW_WeaponSlot {
	L4DW_WeaponSlot_None = -1,
    L4DW_WeaponSlot_Primary = 0,
    L4DW_WeaponSlot_Secondary = 1,
    L4DW_WeaponSlot_Throwable = 2,
    L4DW_WeaponSlot_HeavyHealthItem = 3,
    L4DW_WeaponSlot_LightHealthItem = 4
};

enum L4DW_WeaponId {
    WEPID_NONE,             // 0
    WEPID_PISTOL,           // 1
    WEPID_SMG,              // 2
.....................
}

L4DW_WeaponSlot WeaponSlots[L4DW_WeaponId] = {
    L4DW_WeaponSlot_None,				// WEPID_NONE       waring starts here
    L4DW_WeaponSlot_Secondary,			// WEPID_PISTOL
.......................
};

It is supposed to make a constant list of enums, I don't know why the compiler generate the warning message 'warning 213: tag mismatch enum?' ? I get warning on every line in L4DW_WeaponSlot WeaponSlots[L4DW_WeaponId]. How can I get rid of this warning?

Any ideas? Thanks!
__________________

Last edited by rikka0w0; 10-10-2018 at 11:23.
rikka0w0 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-10-2018 , 17:28   Re: Why 'warning 213: tag mismatch enum?'
Reply With Quote #2

When you use an enum value to index an array, it expects that value's tag to be the tag of the thing you're putting into the array. Here's an example:

PHP Code:
enum enumStructsAreBad {
    
float:aFloat,
    
anInt,
    
Handle:aHandle

If you try to assign to stupidStruct[aFloat] then it's going to want a float. In your code, you're giving it a L4DW_WeaponSlot where it wants an int.

You can view_as every assignment, tag every value in the enum, or make the first letter of L4DW_WeaponSlot lowercase so it's a weak tag.
Fyren is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:52.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode