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
#2

use #undef _inc_filename at the beginning of each file you want to include more as once like #undef _inc_main or #undef _inc_includes

although I dont see a reason here to do that
Reply
#3

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
use #undef _inc_filename at the beginning of each file you want to include more as once like #undef _inc_main or #undef _inc_includes

although I dont see a reason here to do that
found solution, come here to say that and found you message thx anyway

More information:
http://forum.sa-mp.com/showpost.php?...3&postcount=35
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)