본문으로 바로가기

Function Pointer

category 카테고리 없음 2025. 2. 18. 10:32

리눅스 커널을 포팅하다 function pointer의 괜찮은 예제를 발견.

void (*at91_arch_reset)(void);
 
static inline void arch_reset(void)
{
    /* call the CPU-specific reset function */
    if (at91_arch_reset)
    (at91_arch_reset)();
}
 
void at91sam9_alt_reset(void)
{
    printf("reset...\n");
}
 
void main(void)
{
    at91_arch_reset = at91sam9_alt_reset;
 
    arch_reset();
}