Scamjunk said:
I have the following code for a generic stack implementation.
----------------
void Push(void *value, void *Stack, int *top)
{
if(!(IsFull(Stack, top)))
{
(*top)++;
Stack[*top] = *value;
}
}
-------------
and am getting the following error:
error C2036: 'void *' : unknown size
How do i overcome this? Any ideas?
Normally, the exact type of 'Stack' and 'value' would be in your function
declaration. Let's take, for example, 'unsigned long' for each:
void Push(unsigned long *value, unsigned long *Stack, int *top)
However, since you used 'void *' and mentioned 'generic' routines, I suspect
you are trying to push and pop different types of values, and perhaps even
structures, onto the 'Stack'. If so, each type except void, can be
represented as an array of unsigned chars. You'll need to redo your generic
routines for unsigned chars (instead of 'void *'). Then you'll need to
convert the data to pushed or popped to unsigned chars, perhaps via casts or
via memcpy etc., before passing to the stack routines. You'll probably also
need to pass the length of each piece of data, since they will vary in size,
in terms of unsigned chars to the push and pop routines.
Make some changes. Try some stuff. Post some more code. IIRC, someone was
working on this about a month ago.
Rod Pemberton