RE: Using multiple defines!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



oooooooooops!

Figured it out!

it would help if I reference the right structure !!!!!!!!!!!!!!!!!!!!!!!!!

//aGMI declared in header (Not shown!)
#define __CW aGMI[MSG-1].CHARWIDTH
#define __LP aMCB[MSG-1].LEADING_PIX <<<
#define __TP aMCB[MSG-1].TRAILING_PIX <<<
#define __CS aMCB[MSG-1].CHARSPACING <<<

#define __TCW ((__CW -__LP)-__TP)+ __CS


Please excuse my clumsiness!

--
Best regards
Robert


"Robby" wrote:

Hello,

This is not going good!

Can anyone please tell me what is wrong with this. I thought I was getting
organized by defining all my formulas and getting them out of the way of my
code. And now, this:

error: Line 217 (21,22) "element is not a member"
error: Line 240 (26,27) "element is not a member"
error: Line 256 (23,26) "Unidentified identifier __TCW"

Code example
=================================================
int FETCH(
int *A2,
int *A1,
int *A0,
int MSG) {

//aGMI declared in header (Not shown!)
#define __CW aGMI[MSG-1].CHARWIDTH
#define __LP aGMI[MSG-1].LEADING_PIX
#define __TP aGMI[MSG-1].TRAILING_PIX
#define __CS aGMI[MSG-1].CHARSPACING

#define __TCW ((__CW -__LP)-__TP)+ __CS

//CL_B Declared in header not shown!
pCL_B = malloc(__TCW*sizeof(struct CL_B)); //<<<Line 217
...
...
...
LOAD_CHAR_PIXROW(
pCL_B,
__LP, //<<<Line 240
__TP,
__CS,
__TCW);
...
for(j=0;j<TCW;j++) //<<<Line 256
{}
....
================================================

My question is, can we define formulas and then use their tags in other
define directives...! as so:

#define __CW aGMI[MSG-1].CHARWIDTH
#define __LP aGMI[MSG-1].LEADING_PIX
#define __TP aGMI[MSG-1].TRAILING_PIX
#define __CS aGMI[MSG-1].CHARSPACING

//Using other defined tags in this define statement
#define __TCW ((__CW -__LP)-__TP)+ __CS

And can can use any of the defined tags (ex:__TCW) as function parameters!
Right?

I can get my code to compile by doing this in other ways were I have the
parameters of function calls directly access the structure items
spontaneously like this:

LOAD_CHAR_PIXROW(
pCL_B,
aGMI[MSG-1].CHARWIDTH,
aGMI[MSG-1].LEADING_PIX,
aGMI[MSG-1].TRAILING_PIX,
aGMI[MSG-1].CHARSPACING);

But this kaotic... we end up with these long ugly accessings like:

aGMI[MSG-1].CHARWIDTH

in for loops, function parameters and all kinds of expressions which makes
the code very difficult to follow a few months from now. Thats why I wanted
to declare everything at the top with define statements. How do you guys get
all these formulas organized?

Boy oh boy!!!! Asking for help again: :(


--
Best regards
Robert
.



Relevant Pages