AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   #define results in undefined symbol (https://forums.alliedmods.net/showthread.php?t=308261)

xerox8521 06-13-2018 10:21

#define results in undefined symbol
 
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

asherkin 06-13-2018 10:39

Re: #define results in undefined symbol
 
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"?

xerox8521 06-13-2018 10:50

Re: #define results in undefined symbol
 
Right in pawn its (%1,%2) completly forgot that. Thanks.

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


All times are GMT -4. The time now is 12:11.

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