Quick question #define
#1

Hi!

Where should I put: #define code in Pawno?? Sorry for pretty stupid question but i'm pretty new with Pawn...
Have lookt on tutorial but didn't said where to put it ^^

Thanks alot for help!!


(Define for teams and the colour)
Reply
#2

Perhaps somewhere after your includes?
Reply
#3

It is a pre-processor directive and may be located below or above header files or included directives.
Reply
#4

Either under/around your #include lines - or even in an include itself (just to abstract it away).
Reply
#5

Anywhere. You can place it anywhere it fits for you.

Even though, if you want to replace some text globally throughout the Gamemode, I'd suggest you to put on the beginning of the code.
Reply
#6

Quote:
Originally Posted by SmiT
Посмотреть сообщение
Perhaps somewhere after your includes?
Quote:
Originally Posted by funky1234
Посмотреть сообщение
Either under/around your #include lines - or even in an include itself (just to abstract it away).
Definition may also be before included directives.
Reply
#7

Quote:
Originally Posted by Sync'
Посмотреть сообщение
Definition may also be before included directives.
Hence why I said "under/around" - it just makes more logical sense to put them in a specific order. Example:
  • Includes
  • Definitions
  • Global Variable Declarations
  • Callbacks
  • Functions
  • EOF
...though, I guess this is personal preference.
Reply
#8

Thanks so much guys
Reply
#9

I want to add on a bit further. A define is a preprocessor directive and a such may be placed anywhere you want. I tend to do this:

pawn Код:
public OnPlayerDataSaved(query[], index, extraid, connectionHandle)
{
    #define playerid index
   
    // Lots of code
    printf("[data] Playerid %d disconnected. Data was saved and variables were reset.", playerid);
   
    #undef playerid
    return 1;
}
Reply
#10

Vince: Why not replace index by playerid in the function header itself?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)