Quick question #define -
davve95 - 28.11.2011
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)
Re: Quick question #define -
SmiT - 28.11.2011
Perhaps somewhere after your includes?
Re: Quick question #define - Sinc - 28.11.2011
It is a pre-processor directive and may be located below or above header files or included directives.
Re: Quick question #define -
Ash. - 28.11.2011
Either under/around your #include lines - or even in an include itself (just to abstract it away).
Re: Quick question #define -
steki. - 28.11.2011
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.
Re: Quick question #define - Sinc - 28.11.2011
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.
Re: Quick question #define -
Ash. - 28.11.2011
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.
Re: Quick question #define -
davve95 - 28.11.2011
Thanks so much guys
Re: Quick question #define -
Vince - 28.11.2011
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;
}
Re: Quick question #define -
AndreT - 28.11.2011
Vince: Why not replace index by playerid in the function header itself?