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

Enum madness? Structs? What?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 11-07-2016 , 17:26   Enum madness? Structs? What?
Reply With Quote #1

* Compiler used was the latest stable 1.8 build.

I was messing around a bit and i tried using typedefs to create arbitrary types (i found later you can only create typenames for functions)

Anyway, this stuff happened:

Code:
enum {     Chihuahua,     Bulldog } Dog; public void OnPluginStart() {     Dog = 42;     Dog = true;     Dog = Bulldog; }

It gives me no errors, what's going on? I think i'm creating an anonymous enum (fair enough) but what is "Dog", is it a variable? Why can i do whatever i want with it without any errors?

Also, why am i allowed to do this without any errors, perhaps some leftover deprecated pawn code? Methodmap prototype?

Code:
struct Data {     public int some_int;           // It wants the public keyword, otherwise it gets mad.     public char name[32]; } public void OnPluginStart() {     Data data;     //data.some_int                // No errors up til' this point, i'm guessing i'm not allowed to do this because the '.' operator was only implemented for methodmaps. }
__________________
Farbror Godis is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 11-07-2016 , 18:24   Re: Enum madness? Structs? What?
Reply With Quote #2

Quote:
Originally Posted by Farbror Godis View Post
It gives me no errors, what's going on? I think i'm creating an anonymous enum (fair enough) but what is "Dog", is it a variable? Why can i do whatever i want with it without any errors?
You declared a variable named Dog with an anonymous enum as its type.

Quote:
Originally Posted by Farbror Godis View Post
Also, why am i allowed to do this without any errors, perhaps some leftover deprecated pawn code? Methodmap prototype?
It is a feature from original Pawn, but it's been mostly removed. "Mostly" because it's still used for the plugin info struct (which is probably where you saw it?). However, most (but maybe not all) ways to do anything except initialize it are gone.
Fyren 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 16:08.


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