Since theres no typeof operator, how do i find the type of something?
My problem is that i use the wm_lst_t functions and sometimes a list can contain another list so i need to know if an item should be deleted with adl_memRelease or wm_lstDestroy if the item is another list…
I would do something like this in the FreeItem callback:
void itemDeleteCallback(void *Item)
{
if(typeof(wm_lst_t) == Item){
// Item is another list
wm_lst_Destroy(Item);
} else {
adl_memRelease(Item);
}
}
But since the typeof operator doesn’t work, how do i accomplish this?
I made a simple key value dictionary api based on the wm_lst functions. Since it’s generic, i can’t know if an item might be another list or just a standard type that can be deleted with adl_memRelease.
As i see it, my only other alternative would be to pass a FreeItem callback with each key that i create
Oh and how does va_arg do it then?
Chapter 7.3 Variable-length Argument Lists in
The C Programming Language Second Edition
By Brian W. Kerninghan / Dennis M. Ritchie
ISBN: 0-13-110362-8
Page 156:
Exactly - that is why you can get into such a big mess with the likes of printf if the values you pass do not match the specifiers in your format string… 8)