일단 이런 식으로 해서 작동은 함.


#ifndef _TEMPLATE_LIST_H_ #define _TEMPLATE_LIST_H_ #define TEMPLATE_LIST(type) struct list_node_##type; struct list_##type; /* implementation */ #endif


근데 헤더에다 다 때려박아서 그런지 정리가 안 됨.


예를 들어서, 어느 한 파일에 위 매크로를 써서 struct list_int 를 이미 정의한 상태면,


TEMPLATE_LIST(int)


다른 파일에서 그 존재를 모르고 똑같이 매크로를 썼을 때 타입 간의 충돌로 에러가 나잖아.


그걸 해결하기 위해서 헤더 분리 후 extern struct 로 매크로 쓰려고 하는데 가능할까?


#ifndef _TEMPLATE_LIST_H_ #define _TEMPLATE_LIST_H_ #define TEMPLATE_LIST(type) extern struct list_node_##type; extern struct list_##type; /* implementation now moved to .c */ #endif


근데 문제점은 implementation이 c 파일에 있다면 어느 타입의 STL이 쓰이는지


컴파일 타임에 알려져야 할 텐데 어떻게 해야할지 막막하네.