C , C++, C#

복잡한 선언 읽기: C / C++

vhxpffltm 2022. 6. 21. 20:46
반응형

어쩌다 여러방면의 코드를 얘기한 적이 있었는데..

 

복잡한 구문을 쉽게 읽고 쓸수 있는 방안이 있다고 했다.

 

찾아보니 나선 방향?으로 읽고 이해하면 쉽다고 했다.

 

C에서 Signal 라이브러리 함수를 읽을정도면 완벽히 이해한 것이다.

 

아래 간단한 예제는 우리 모두 무슨 의미인지 쉽게 알 수 있다.

 

const char *chptr; // pointer to char const
	char * const chptr;  //const pointer to char
	volatile char * const chptr;  // const pointer to chat vo..

 

 

문제는 아래와 같은 예제들이다.

 

아래 참조를 통해 공부해보자.

 

char *(*fp)( int, float *);
void (*signal(int, void (*fp)(int)))(int);

 

 

 

http://c-faq.com/decl/spiral.anderson.html

 

Clockwise/Spiral Rule

[This was posted to comp.lang.c by its author, David Anderson, on 1994-05-06.] --> The ``Clockwise/Spiral Rule'' By David Anderson There is a technique known as the ``Clockwise/Spiral Rule'' which enables any C programmer to parse in their head any C decla

c-faq.com

 

https://cdecl.org/

 

cdecl: C gibberish ↔ English

 

cdecl.org

 

https://medium.com/@bartobri/untangling-complex-c-declarations-9b6a0cf88c96

 

Untangling Complex Declarations in C

Here is a list of C declarations of increasing complexity. Until recently I could not have told you what all of them meant.

medium.com

 

 

반응형