pointer to PE macro defined

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

pointer to PE macro defined

ソリューションへジャンプ
831件の閲覧回数
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 解決策
361件の閲覧回数
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 返信
362件の閲覧回数
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 件の賞賛