Raised This Month: $ Target: $400
 0% 

[REQ] Static Enums


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
souvikdas95
Senior Member
Join Date: Mar 2012
Old 04-03-2014 , 14:28   [REQ] Static Enums
Reply With Quote #1

Can AmxModX introduce support for static enums like :

Code:
public client_putinserver ( id )
{
	static enum _:TEST
	{
		iNum1 = 0,
		iNum2,
		szString[128]
	}

	new DATA[TEST];
}

Last edited by souvikdas95; 04-03-2014 at 14:28.
souvikdas95 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 04-03-2014 , 15:52   Re: [REQ] Static Enums
Reply With Quote #2

Make global?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-03-2014 , 17:11   Re: [REQ] Static Enums
Reply With Quote #3

Don't XY, explain what your trying to do.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-03-2014 , 17:52   Re: [REQ] Static Enums
Reply With Quote #4

+ I'm not sure why you're even 'requesting' something in "Scripting section". You know perfectly that's not the right place. But yes, explain yourself, you could just make the enum global.
__________________
Arkshine is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 04-05-2014 , 07:09   Re: [REQ] Static Enums
Reply With Quote #5

The compiler seems to be fine with function-scope enumerations, though I'm curious whether they're initialized on startup or when the function is called.
__________________

Last edited by hleV; 04-05-2014 at 07:09.
hleV is offline
souvikdas95
Senior Member
Join Date: Mar 2012
Old 04-05-2014 , 07:14   Re: [REQ] Static Enums
Reply With Quote #6

Uhm... Suppose I want to reuse the symbols in that enum in another function but I don't want to use that same enum or redeclaring it as many times as the function is called. So, how do I do that?
Making it global returns compilation errors saying symbol already declared or so...

@Arkshine - I have some problems with understanding where to post what Can you shift this thread to the required section?

Last edited by souvikdas95; 04-05-2014 at 07:25.
souvikdas95 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-05-2014 , 08:15   Re: [REQ] Static Enums
Reply With Quote #7

Quote:
Originally Posted by souvikdas95 View Post
Uhm... Suppose I want to reuse the symbols in that enum in another function but I don't want to use that same enum or redeclaring it as many times as the function is called. So, how do I do that?
Making it global returns compilation errors saying symbol already declared or so...
This is the right section for this kind of post.
It's because you're trying to declare something twice. If you would've shown the real code and the real error we would be able to help you. Without that I can only tell you to change the variable names of/in the enum.
Neither of these are ok:
Code:
new Test1 enum Test1 {     Whatever } new Test2 enum Whatever2 {     Test2 }

Code:
N:\Nerladdat\! Spel\CS\! Scripting\Rose\test4.sma(4) : error 021: symbol already defined: "Test1"
N:\Nerladdat\! Spel\CS\! Scripting\Rose\test4.sma(11) : error 021: symbol already defined: "Test2"
__________________

Last edited by Black Rose; 04-05-2014 at 08:15.
Black Rose is offline
souvikdas95
Senior Member
Join Date: Mar 2012
Old 04-05-2014 , 08:54   Re: [REQ] Static Enums
Reply With Quote #8

hmm... so my request is valid right?

Code:
function()
{
	static enum _:test
	{
		num1,
		num2,
		name[32];
	}
	static DATA[test];
}

function2()
{
	new name[64],num1,num2;
}
I want this to be valid.

Last edited by souvikdas95; 04-05-2014 at 08:58.
souvikdas95 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-05-2014 , 09:00   Re: [REQ] Static Enums
Reply With Quote #9

Nope. Make the enum global. You don't have to make the DATA global though. But the difference between global and static is none I believe.
__________________
Black Rose is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-05-2014 , 11:59   Re: [REQ] Static Enums
Reply With Quote #10

Quote:
Originally Posted by Black Rose View Post
Nope. Make the enum global. You don't have to make the DATA global though. But the difference between global and static is none I believe.
There is a difference between global and static variables: scope. However, apparently, enum's don't seem to work as static.
__________________
fysiks 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 05:57.


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