Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (TipmyPip, Quad), 3,808 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
namespacing #257015
03/20/09 02:53
03/20/09 02:53
Joined: Dec 2008
Posts: 43
D
DavidM Offline OP
Newbie
DavidM  Offline OP
Newbie
D

Joined: Dec 2008
Posts: 43
I find myself sometimes inadvertently conflicting with some globals in A7 ( result, target, hit, etc ) mostly because these are common English words.

Could these be put into a static struct such as:

struct {
VECTOR hit;
VECTOR target;
VAR result;
...
} Acknex;

I understand this would break some scripts but it would make for a much cleaner API.

I am not sure if you could alias these in a compatibility header which had some declarations like:

VAR* result = &Acknex.result;
VECTOR* target = &Acknex.target;

-DavidM

Re: namespacing [Re: DavidM] #257044
03/20/09 08:00
03/20/09 08:00
Joined: Jul 2000
Posts: 28,094
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,094
Frankfurt
Those common names are replaced by the hit struct long ago, but have to be still around for compatibility. I'd be teared and feathered by the community if I would follow your advice.

Re: namespacing [Re: jcl] #257583
03/24/09 04:03
03/24/09 04:03
Joined: Dec 2008
Posts: 43
D
DavidM Offline OP
Newbie
DavidM  Offline OP
Newbie
D

Joined: Dec 2008
Posts: 43
So there is no way to redefine locally the global variables?

Its really error prone to preserve the word "result" to always point somewhere in the API.(and target, hit, etc).

I define it as a passed parameter and it just shows up zeroed out, until I realize its reserved.

Re: namespacing [Re: DavidM] #257584
03/24/09 04:13
03/24/09 04:13
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
use a type_def struct to make your variables to a certain scope and thus making sure it doesnt point to any core variables defined in the engine. e.g.

Code:
typedef struct 
{
	ENTITY* entAgent;
	int ID;
	var x;
	var result;
	var zpos;
	var timestamp;
	var exist;
	var dead;
	
} structMyVars;

structMyVars myVar;



To access use myVar.result, etc.. for all the members. I understand that this is not memory efficient if u mite need only one member sometimes. But u can do this for all ur normal variables.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: namespacing [Re: DavidM] #257704
03/25/09 01:49
03/25/09 01:49
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
i just use underscores, and self defs are _ and skill defs are __ saves me any problems


Moderated by  aztec, Spirit 

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