Raised This Month: $32 Target: $400
 8% 

enum and native tag mismatch


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Hop
Junior Member
Join Date: Jun 2016
Old 04-03-2017 , 23:44   enum and native tag mismatch
#1

I'm trying to compile this in SourceMod 1.8+, I removed the enum re-tagging since that causes errors but I'm not sure how to redo this part without getting errors, hopefully someone can point me in the right direction, thanks.
PHP Code:
enum
{
String:sName[8],
bool:bEnabled[2],
ConfigSize
};

[...]

any g_aConfig[8][ConfigSize];

[...]

if(
g_aConfig[ID][Enabled][Type]) 
PHP Code:
error 001expected token")"but found "["
error 029invalid expressionassumed zero
warning 215
expression has no effect
error 001
expected token";"but found "]"
fatal error 190too many error messages on one line 

Last edited by sneaK; 12-13-2017 at 19:25. Reason: restored blanked post
Hop is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-04-2017 , 10:38   Re: enum and native tag mismatch
#2

As far as I know, you can use enums as structs with a newer compiler as long as you declare everything using the older syntax.

Something like your above can't work because your array is literally just "any g_aConfig[8][10]". Trying to throw on another dimension is wrong.

What was the code you used originally?
Fyren is offline
Hop
Junior Member
Join Date: Jun 2016
Old 04-04-2017 , 17:20   Re: enum and native tag mismatch
#3

Quote:
Originally Posted by Fyren View Post
As far as I know, you can use enums as structs with a newer compiler as long as you declare everything using the older syntax.

Something like your above can't work because your array is literally just "any g_aConfig[8][10]". Trying to throw on another dimension is wrong.

What was the code you used originally?
Before this I was compiling in in 1.6.0 and it was like this:
PHP Code:
enum _:Config
{
    
String:Name[8],
    
bool:bEnabled[2]
};

[...]

new 
g_iConfig[8][Config];

[...]

if(
g_iConfig[Name][Enabled][ID]) 
Hop is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-04-2017 , 19:57   Re: enum and native tag mismatch
#4

Do you have a reason for tagging the enum itself? It works as I'd expect if you don't.
Fyren is offline
Hop
Junior Member
Join Date: Jun 2016
Old 04-04-2017 , 20:05   Re: enum and native tag mismatch
#5

Quote:
Originally Posted by Fyren View Post
Do you have a reason for tagging the enum itself? It works as I'd expect if you don't.
The tag isn't necessary and that's not what's causing the problem it's trying to access the 2 values in bEnabled, as far as I know it was tagged so it could be used to set the config size.

Last edited by Hop; 04-04-2017 at 20:06.
Hop is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-05-2017 , 01:36   Re: enum and native tag mismatch
#6

With your second snippet but without tagging the enum itself, you can access them as, for example, g_iConfig[0][bEnabled][0] or g_iConfig[0][bEnabled][1]. I have no idea what your "Enabled" or "ID" are since you didn't provide them.
Fyren is offline
Hop
Junior Member
Join Date: Jun 2016
Old 04-05-2017 , 04:32   Re: enum and native tag mismatch
#7

Quote:
Originally Posted by Fyren View Post
With your second snippet but without tagging the enum itself, you can access them as, for example, g_iConfig[0][bEnabled][0] or g_iConfig[0][bEnabled][1]. I have no idea what your "Enabled" or "ID" are since you didn't provide them.
Your values are pretty much what Enabled and ID would be, so now I have added what you said there's 2 tag mismatch and 1 index tag mismatch errors on SetNativeArray. The last one goes away if I use view_as<int> on ConfigSize but I'm not sure if that's right.
PHP Code:
enum Config
{
    
String:Name[8],
    
bool:bEnabled[2],
    
ConfigSize
};

[...]

int iConfig GetNativeCell(1);
SetNativeArray(2g_aConfig[iConfig], ConfigSize); 
PHP Code:
warning 213tag mismatch
warning 229
index tag mismatch (symbol "g_aConfig")
warning 213tag mismatch 
Hop is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-05-2017 , 20:36   Re: enum and native tag mismatch
#8

You can name your enum starting with a lowercase letter to resolve all three warnings. Uppercase tags warn on implicit conversions, lowercase do not. This (and enums as structs in the first place) are holdovers from the original, upstream Pawn.
Fyren is offline
Hop
Junior Member
Join Date: Jun 2016
Old 04-05-2017 , 23:21   Re: enum and native tag mismatch
#9

Quote:
Originally Posted by Fyren View Post
You can name your enum starting with a lowercase letter to resolve all three warnings. Uppercase tags warn on implicit conversions, lowercase do not. This (and enums as structs in the first place) are holdovers from the original, upstream Pawn.
Awesome, thank you so much.
Hop is offline
Closed Thread


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 17:14.


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