Raised This Month: $51 Target: $400
 12% 

Solved Fix this > Array-based enum structs will be removed in 1.11.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-12-2020 , 04:38   Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #1

How to fix this warning? warning 241: Array-based enum structs will be removed in 1.11.

PHP Code:
enum ListingRoles
{
    
Role_One 0,
    
Role_Two,
    
Role_Three,
    
Role_Four,
    
Role_Five,
    
Role_Six,
}

ListingRoles g_iRole[MAXPLAYERS 1]; //Stores information roles of each player

int g_iCounterRoles[Listing]; // <<< Warning on this line 

Last edited by Hennesy; 06-12-2020 at 07:26.
Hennesy is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-12-2020 , 05:08   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #2

https://wiki.alliedmods.net/SourcePa...x#Enum_Structs

There is a new syntax for this kind of data structure which you can switch to, but the way you're using it, as an index into an array of integers, allows for an easier change

PHP Code:
enum ListingRoles
{
    
Role_One 0,
    
Role_Two,
    
Role_Three,
    
Role_Four,
    
Role_Five,
    
Role_Six,
    
Role_Max
}

ListingRoles g_iRole[MAXPLAYERS 1]; //Stores information roles of each player

int g_iCounterRoles[Role_Max]; // <<< Warning on this line 
Instead of setting the whole ListingRoles enum as the array dimension, just add an additional "ending" element to the enum marking the maximum ordinal value of the enum and use that as the array dimension.
__________________
Peace-Maker is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-12-2020 , 05:25   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #3

Quote:
Originally Posted by Peace-Maker View Post
https://wiki.alliedmods.net/SourcePa...x#Enum_Structs

There is a new syntax for this kind of data structure which you can switch to, but the way you're using it, as an index into an array of integers, allows for an easier change

PHP Code:
enum ListingRoles
{
    
Role_One 0,
    
Role_Two,
    
Role_Three,
    
Role_Four,
    
Role_Five,
    
Role_Six,
    
Role_Max
}

ListingRoles g_iRole[MAXPLAYERS 1]; //Stores information roles of each player

int g_iCounterRoles[Role_Max]; // <<< Warning on this line 
Instead of setting the whole ListingRoles enum as the array dimension, just add an additional "ending" element to the enum marking the maximum ordinal value of the enum and use that as the array dimension.
Warning remains as before
warning 241: Array-based enum structs will be removed in 1.11.
Hennesy is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-12-2020 , 05:38   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #4

Interesting. That looks like a bug to me since it works with the 1.11 compiler.

You can work around it like this:
PHP Code:
int g_iCounterRoles[view_as<int>(Role_Max)]; 
__________________
Peace-Maker is offline
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 06-12-2020 , 07:26   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #5

Quote:
Originally Posted by Peace-Maker View Post
Interesting. That looks like a bug to me since it works with the 1.11 compiler.

You can work around it like this:
PHP Code:
int g_iCounterRoles[view_as<int>(Role_Max)]; 
Thanks you. Thread solved

Last edited by Hennesy; 06-12-2020 at 07:27.
Hennesy is offline
thEsp
BANNED
Join Date: Aug 2017
Old 06-12-2020 , 07:43   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #6

What's really the point of removing them?
thEsp is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-12-2020 , 07:59   Re: Fix this > Array-based enum structs will be removed in 1.11.
Reply With Quote #7

This should work:

PHP Code:
enum ListingRoles// Note the :
{
    
Role_One 0,
    
Role_Two,
    
Role_Three,
    
Role_Four,
    
Role_Five,
    
Role_Six,
    
Role_Max
}

ListingRoles g_iRole[MAXPLAYERS 1];

int g_iCounterRoles[Role_Max]; 
__________________

Last edited by asherkin; 06-12-2020 at 07:59.
asherkin is offline
Reply



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:52.


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