✅ 목표 (Goal)

typedef 를 사용하면 콜백함수를 훨씬 더 깔끔하게 사용할수 있다.

✅ typedef 하기 전의 간단한 예제를 하나 만들자.

아래는 간단한 함수포인터의 예이다

bts, exo 함수는 호출하기 위해 만든것일뿐 별 의미가 없으니 내용은 신경쓰지 말자.

#include <stdio.h>

#include <stdint.h>
#include <stdbool.h>

void bts(int a, int b) {
	printf("%d + %d = %d\\r\\n", a, b, a + b);
}

int exo(int a, int b, int c) {
	return (a + b + c);
}

int main() {
	void (*fp1)(int a, int b);
	fp1 = bts;

	int (*fp2)(int, int, int);
	fp2 = exo;

	fp1(2, 3);
	int r = fp2(11, 22, 33);
	printf("%d\\r\\n", r);

	return 0;
}

Untitled

✅ 함수 포인터도 typdef로 간략하게 줄일수 있다.

Untitled

인자로 받는 함수포인터가 너무 길다.

아래와 같이 재정의 한다음에..

Untitled