There are 1 articles in 'cdecl'
  1. 2006/07/10 복잡한 선언을 분석하는 법

2006/07/10 00:23

복잡한 선언을 분석하는 법

http://wiki.kldp.org/wiki.php/CLangaugeComplexDeclaration

위를 참고하면 어느정도는 쉽게 해결할 수 있다.
cdecl 라는 유틸리티가 있는데
$ sudo apt-get install cdecl 로 간단히 설치할 수 있다.

사용법은 help 를 처보면 된다.
아래는 간단한 사용법.

missu@missu-laptop:~$ cdecl
Type `help' or `?' for help
cdecl> explain void *(*my_func)(int, struct _name)[]
declare my_func as pointer to function (int, struct _name) returning array of pointer to void
cdecl> explain int *name[]
declare name as array of pointer to int
cdecl> explain int (*name)[]
declare name as pointer to array of int

비록 영어로 나오기는 하지만, 도저히 모르겠을때 explain 으로 한번 영어로된 결과를 보고나서 다시 생각해보면 그나마 좀 더 쉽게 접근할 수 있다. 사실은 그전에 typedef 로 가독성이 떨어지는 선언은 하지 않는 것이 바람직 하겠지만..

아래는 보너스. 과연 이런것을 쓸일이 프로그램짜면서 생길런지...
cdecl> explain void (*(*signal)(int,void(*)(int)))(int);
declare signal as pointer to function (int, pointer to function (int) returning void) returning pointer to function (int) returning void


2006/07/10 00:23 2006/07/10 00:23
[top]
TAG :: ,