Explain this !

R

Ravi Uday

Hi,

Can anybody explain this..

#define LIST_DESTROY(a) list_destroy(a)
#define LIST_ENQUEUE(a, b, c) list_enqueue(a,b,c)
#define LIST_REMOVE(a, b, c) list_remove(a,b,c)
etc...


#define LIST_DESTROY(a) NULL
#define LIST_ENQUEUE(a, b, c) NULL
#define LIST_REMOVE(a, b, c) NULL
#define LIST_HEAD_ELEMENT(a) NULL
#define LIST_GET_DATA(a) NULL
#define LIST_NEXT_ELEMENT(a) NULL
#define LIST_EMPTY(a) NULL

#define FOR_ALL_DATA_IN_LIST(__list, __element, __data) \
for (__element = LIST_HEAD_ELEMENT(__list), \
__data = LIST_GET_DATA(__element); \
__element != NULL; \
__element = LIST_NEXT_ELEMENT(__element), \
__data = LIST_GET_DATA(__element))


Though the name of the MACRO is self-explanatory what i dont understand is
the second list of #define's - why are they defined as NULL

Thanks,
- Ravi
 
R

Ronald Landheer-Cieslak

Ravi said:
Can anybody explain this.. Possibly..

#define LIST_DESTROY(a) list_destroy(a)
#define LIST_ENQUEUE(a, b, c) list_enqueue(a,b,c)
#define LIST_REMOVE(a, b, c) list_remove(a,b,c)
etc...


#define LIST_DESTROY(a) NULL
#define LIST_ENQUEUE(a, b, c) NULL
#define LIST_REMOVE(a, b, c) NULL
#define LIST_HEAD_ELEMENT(a) NULL
#define LIST_GET_DATA(a) NULL
#define LIST_NEXT_ELEMENT(a) NULL
#define LIST_EMPTY(a) NULL

#define FOR_ALL_DATA_IN_LIST(__list, __element, __data) \
for (__element = LIST_HEAD_ELEMENT(__list), \
__data = LIST_GET_DATA(__element); \
__element != NULL; \
__element = LIST_NEXT_ELEMENT(__element), \
__data = LIST_GET_DATA(__element))


Though the name of the MACRO is self-explanatory what i dont understand is
the second list of #define's - why are they defined as NULL
In divination mode, I'd say there's probably an #if or an #ifdef
somewhere, but I think this link may be helpful:
http://www.catb.org/~esr/faqs/smart-questions.html

HTH

rlc
 
V

vir

Ravi said:
Hi,

Can anybody explain this..

#define LIST_DESTROY(a) list_destroy(a)
#define LIST_ENQUEUE(a, b, c) list_enqueue(a,b,c)
#define LIST_REMOVE(a, b, c) list_remove(a,b,c)
etc...


#define LIST_DESTROY(a) NULL
#define LIST_ENQUEUE(a, b, c) NULL
#define LIST_REMOVE(a, b, c) NULL
#define LIST_HEAD_ELEMENT(a) NULL
#define LIST_GET_DATA(a) NULL
#define LIST_NEXT_ELEMENT(a) NULL
#define LIST_EMPTY(a) NULL

#define FOR_ALL_DATA_IN_LIST(__list, __element, __data) \
for (__element = LIST_HEAD_ELEMENT(__list), \
__data = LIST_GET_DATA(__element); \
__element != NULL; \
__element = LIST_NEXT_ELEMENT(__element), \
__data = LIST_GET_DATA(__element))


Though the name of the MACRO is self-explanatory what i dont understand is
the second list of #define's - why are they defined as NULL

Thanks,
- Ravi
It's seems that the user of this library must provide his redefinitions
of macroses that have been defined as NULL to use this. The main purpose
is something like C++ template construction. I don't know the details
and I can't comment the design. Sometimes it's better to use void*
instead of macroses in C. But if you really need lots of generic
procedures try switching to C++.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top