How to include same file few times?
#1

I would like to do some "clever" but pretty easy macros, to initiate variables from all includes, and then after all variables are collected, define functions.

for example:

Player.pwn:
pawn Код:
#if defined INIT_VARIABLES

enum ePlayer{ pa, pb, pc };
new player[MAX_PLAYERS][ePlayer];

#else

stock LoadPlayer(playerid) { return 1; }
stock PlayerHaveJob(playerid) { return player[playerid][pa]; }
#endif
Jobs.pwn:
pawn Код:
#if defined INIT_VARIABLES

enum eJobsList { ja, jb, jc };
new jobs[eJobsList];

#else

stock HirePlayer(playerid, jobid)
{
    if(!PlayerHaveJob(playerid) && player[playerid][pb])
        player[playerid][pa] = jobid;
}
#endif
Includes.pwn:
pawn Код:
#include "Player.pwn"
#include "Jobs.pwn"
Main.h:
pawn Код:
#include <a_samp>
#define INIT_VARIABLES
#include "Includes.pwn"
Main.pwn:
pawn Код:
#include "Main.h"
#undef INIT_VARIABLES
#include "Includes.pwn" // this is not called
main(){}
Reply


Messages In This Thread
How to include same file few times? - by theYiin - 24.11.2013, 19:09
AW: How to include same file few times? - by Nero_3D - 24.11.2013, 19:45
Re: AW: How to include same file few times? - by theYiin - 24.11.2013, 19:57

Forum Jump:


Users browsing this thread: 1 Guest(s)