C언어 매크로 사용 중 에러가 납니다.
글쓴이: smallhuman / 작성시간: 화, 2014/03/04 - 10:57오후
#include <stdio.h>
#include <stdbool.h>
struct list_elem {
struct list_elem *prev;
struct list_elem *next;
};
(중략)
struct record {
char s_no[10];
char s_name[20];
char dept[20];
char addr[40];
struct list_elem elem;
};
(중략)
#define list_entry (LIST_ELEM, STRUCT, MEMBER) \
((STRUCT *) ((char *) &(LIST_ELEM)->next \
- offsetof (STRUCT, MEMBER.next)))
int main(void){
struct record *a = (struct record*) malloc(sizeof (struct record));
struct record *b;
struct list_elem *c = &(a->elem);
b = list_entry(c , struct record, elem);
printf("%x \\ %x \n", a, b);
return 0;
}저기에서 c = list_entry 부분에서 "expected expression before 'struct'" 라는 에러가 나네요.
음... 다른 프로젝트에서는 잘 쓰던 매크로인데 왜 안 되는지 영문을 모르겠습니다..;;
Forums:


offsetof 에 대한 정의가
offsetof 에 대한 정의가 빠져있어서요..
stddef.h 를 인크루드하세요~
댓글 달기