pointer to PE macro defined

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

pointer to PE macro defined

Jump to solution
781 Views
mvergaracid
Contributor I

Hi:

 

I have this macro in my project:

 

#define Col1_GetVal() ( \
    (bool)((getReg8(PTAD) & 0x10))     /* Return port data */ \
  )

 

I have severals Colx_GetVal macros and i need use a array of pointers to them:

 

ptr[0]= &Col1_GetVal;

ptr[1]= &Col2_GetVal;

 

and so....

 

Anybody can give me some tip how i can o it?

 

Best Regards.

 

Mauricio.

Labels (1)
0 Kudos
1 Solution
311 Views
kef
Specialist I

macros don't have address, thus pointers can't point to macros.

But you may convert macros into functions like this

 

bool Col1_GetVal(void)

 {

    (bool)((getReg8(PTAD) & 0x10))     /* Return port data */ \
}

 

Define array of pointers :

 

char (*array[3])(void);

 

   array[2] = &foo; // assign
  
   array[2](); // call foo

 

To call PE macros proceed like above, but define your own functions and make them calling PE macros.

View solution in original post

0 Kudos
1 Reply
312 Views
kef
Specialist I

macros don't have address, thus pointers can't point to macros.

But you may convert macros into functions like this

 

bool Col1_GetVal(void)

 {

    (bool)((getReg8(PTAD) & 0x10))     /* Return port data */ \
}

 

Define array of pointers :

 

char (*array[3])(void);

 

   array[2] = &foo; // assign
  
   array[2](); // call foo

 

To call PE macros proceed like above, but define your own functions and make them calling PE macros.

0 Kudos