Raised This Month: $170 Target: $400
 42% 

#define results in undefined symbol


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xerox8521
Senior Member
Join Date: Sep 2011
Old 06-13-2018 , 10:21   #define results in undefined symbol
Reply With Quote #1

Hi,

for some reason a #define results in a undefined symbol "CHANGE_FLAGS" error. Which is weird as is its based upon this code: https://github.com/ValveSoftware/sou...hared.cpp#L175

PHP Code:
#define CHANGE_FLAGS(flags,newFlags) (flags = (newFlags)) 
Used in a function like this.

PHP Code:
stock void AddTankImmunityFlag(int tankint flags)
{
    
CHANGE_FLAGSTankInfo[tank][tImmunity], TankInfo[tank][tImmunity] | flags );

SM Compiler Version: 1.8.0.6041

Last edited by xerox8521; 06-13-2018 at 10:24.
xerox8521 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-13-2018 , 10:39   Re: #define results in undefined symbol
Reply With Quote #2

SourcePawn is not C++, the syntax is completely wrong, and function macros are deprecated.

The correct SourcePawn syntax is something like this:
Code:
#define CHANGE_FLAGS(%1,%2) (%1 = (%2))
The correct way to do helper functions is to write real functions:
Code:
stock void CHANGE_FLAGS(int &flags, int newFlags) {
    flags = newFlags;
}
But... why not just write that one line of code rather than obfuscating it behind a "helper"?
__________________
asherkin is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 06-13-2018 , 10:50   Re: #define results in undefined symbol
Reply With Quote #3

Right in pawn its (%1,%2) completly forgot that. Thanks.

Took the sdk code as is without much more looking or thinking about it.
xerox8521 is offline
Reply


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 15:11.


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