Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 16,302 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
macros question #427662
08/11/13 17:52
08/11/13 17:52
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline OP
Member
Arrovs  Offline OP
Member

Joined: Apr 2006
Posts: 159
Latvija
I wish to write this macros, but compiler dont want to accept it.

example here

#define this(struct, function, parameters...) struct.function(struct ,##parameters)

This should let me use any number of parameters and delete comma if im not using parameters, but lite-c somehow dont know this things or im doing it wrong here. I really could apreciate some help.


Arrovs once will publish game
Re: macros question [Re: Arrovs] #427670
08/11/13 20:51
08/11/13 20:51
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline OP
Member
Arrovs  Offline OP
Member

Joined: Apr 2006
Posts: 159
Latvija
seems lite-c compiler accepts only __VA_ARGS__

So at end i managed to get what i wanted, but didnt bothered to make one multifunctional, but 2 ones which is good too.

#define this(struct, function) struct.function(struct)
#define thisp(struct, function, __VA_ARGS__) struct.function(struct, __VA_ARGS__)

target was to make something more object oriented.

Now i can make things like this.

typedef struct Human
{
all properties ..
//all functions
function walk(void* me);//as Human* pointer cant be used before struct is defined
function look_to(void* me, void* you);
}Human;

function walk(Human* human)
{do_something...}

function look_to(Human* me, Human* you)
{do_looking...}

Human_inic()
{
Human* lok_human = new(Human);//again macros which allocates memory
//-->all human properties
//and human function adding
lok_human.walk = walk;
lok_human.look_to = look_to;
return lok_human;
}

function main()
{
Human* lok_human = Human_inic();
Human* lok_other_human = Human_inic();
this(lok_human, walk);
thisp(lok_human, look_to, lok_other_human);
}

Last edited by Arrovs; 08/11/13 20:53.

Arrovs once will publish game

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1