Page 1 of 1

typeof() and extern

Posted: Mon Feb 06, 2012 10:30 am
by afritmans
Hi everyone!

I'm strugling with the following problem in TCC. I wrote some general linked list functions, like the one below:

Code: Select all

#define klibLinkedListPopFront(list)             \
    ({                                           \
        typeof(list) tmpItem = list;             \
		if(list != NULL)                         \
		{                                        \
		    list = tmpItem->next;                \
		    tmpItem->next = NULL;                \
	    }                                        \
		tmpItem;                                 \
	})
Most of the time, this works quite good. But when I try to use this function on a list which is declared as 'extern 'in a header file:

Code: Select all

// In header file:
extern PCB* readyQueue;
// In C file:
klibLinkedListPopFront(readyQueue);
The linker compains about 'undefined reference tmpItem', because

Code: Select all

typeof(list) tmpItem
becomes

Code: Select all

extern PCB* tmpItem
Is this normal behavior, or a TCC bug? Anyone knows an easy way to make my list generic?

Thanks in advance!

Re: typeof() and extern

Posted: Thu Feb 23, 2012 10:18 am
by JamesM
Anyone knows an easy way to make my list generic?
Use casts to void*, which is the "C way", or use C++.