Nginx 읽 기: typedef 정의 함수 포인터 형식
/*function point definition*/
typedef u_char *(*ngx_log_handler_pt) (ngx_log_t *log, u_char *buf, size_t len);
struct ngx_log_s {
ngx_uint_t log_level;
ngx_open_file_t *file;
ngx_atomic_uint_t connection;
ngx_log_handler_pt handler; //function ptr definition
void *data;
/*
* we declare "action" as "char *" because the actions are usually
* the static strings and in the "u_char *" case we have to override
* their types all the time
*/
char *action;
ngx_log_t *next;
};
여기 ngxlog_handler_pt 형식 은 복잡 한 함수 포인터 에 대한 대체 로 사용 하기에 더욱 편리 하 며 매개 변수 유형 이 같 으 면 ngxlog_handler_pt 형식 은 변경 함 수 를 가리 키 고 호출 할 수 있 습 니 다. 예 를 들 어:
이 예 는 다음 과 같 습 니 다:http://www.cnblogs.com/csyisong/archive/2009/01/09/1372363.html, type: def 와 \ # define 에 대한 설명, 짱!
#include <iostream>
using namespace std;
typedef int (*A) (char, char);
int ss(char a, char b)
{
cout<<"in func ss()"<<endl;
cout<<a<<endl;
cout<<b<<endl;
return 0;
}
int bb(char a, char b)
{
cout<<"in func bb()"<<endl;
cout<<b<<endl;
cout<<a<<endl;
return 0;
}
int main()
{
A a;
a = ss;
a('a','b');
a = bb;
a('a', 'b');
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
콜백 함수를 Angular 하위 구성 요소에 전달이 예제는 구성 요소에 함수를 전달하는 것과 관련하여 최근에 직면한 문제를 다룰 것입니다. 국가 목록을 제공하는 콤보 상자 또는 테이블 구성 요소. 지금까지 모든 것이 구성 요소 자체에 캡슐화되었으며 백엔드에 대한 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.