Computer Chess Club Archives


Search

Terms

Messages

Subject: a struct or just a new file ? (C question)

Author: Georg v. Zimmermann

Date: 05:07:28 07/13/02


To further improve the readability of my program I decided to group all clock
related functions (setting the level, checking whether time is out etc)
together. Those are using some of the few global variables I have left.

To do that I just created a clockStruct which has

struct clockStruct
{
public:

void setLevel(int fixedTime, int fixedDepth, int timeInc, int timeBase);
int timeToMove();
[...]

private:
int timeOnClock[COLORS];
int timeBase;
int timeInc;

double clockAtLastMove;
[...]
}

Today it occured to me that instead I can just move all clock related functions
to one file and thus the variables like timeOnClock[COLORS] would have limited
scope restricted to the clock functions as well.


Question now is what you think is the better coding standart ?
Also, does the compiler care about that at all or is the generated code similar
? AFAIK the above options only "protect" the variables from bad coding style so
internally it should not matter. Or does using a struct group the vars closer
together in memory? If so, is that good (because all those vars are used
together and are not needed outside the non-time-critical clock functions) or
bad (because the compiler has less freedom).

Any hints appreciated,

Georg

PS.
I need an utility that can strip code off all lines between
#ifdef GARBAGE
#endif
if GARBAGE is undefined. Anyone know of one ? That would be great.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.