This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Enum Structs Available This Holiday Season


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ainn
New Member
Join Date: Nov 2020
Old 11-26-2020 , 20:01   Re: Enum Structs Available This Holiday Season
Reply With Quote #1

First of all, thanks for the useful feature.

I'm curious, is this a bug or working as intended:

PHP Code:
// This compiles (SourcePawn Compiler 1.10)

enum struct Foo {
    
int a;
    
    
int bar()
    {
        
int b this.a;
        return 
b;
    }
}

public 
void OnPluginStart()
{
    
Foo foo;
    
foo.bar();

But this doesn't work, regardless of the pragma.
PHP Code:
// This doesn't compile:
//     plugin.sp(10) : error 147: new-style declarations are required

#pragma newdecls optional

enum struct Foo {
    
int a;
    
    
int bar()
    {
        new 
this.a// old-style decl
        
return b;
    }
}

public 
void OnPluginStart()
{
    
Foo foo;
    
foo.bar();

While you might wonder why I'd want to do this in the first place, I ran into the issue while using some legacy boilerplate for a newer project. Not a big deal having to rewrite it in newdecls style, but just wondering whether the pragma is actually supposed to allow this.

Last edited by ainn; 11-26-2020 at 20:07.
ainn 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 20:34.


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