pointer to PE macro defined

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

pointer to PE macro defined

跳至解决方案
1,270 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
800 次查看
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 项奖励
回复
1 回复
801 次查看
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 项奖励
回复