L
LordHog
Hello all,
I am having a little problem getting my (void *) assignment to work
correctly. Basically it is some code for a circular queue buffer I am
trying to implement, but getting the deferrencing of the (void *) type
is giving me problems... For brevity sake not all the functions are
defined, but the name gives a clue to what it does...
[------------Code Begins------------]
#define FAIL 0x01
#define SUCCESS 0x00
typedef unsigned long UINT32;
typedef struct {
void* data[CBQ_MAX_QUEUE_SIZE];
INT8 head,
tail;
} CIRCULAR_BUF_DESCRIPTOR;
STATUS_RESULT_TYPE PopCbq( CIRCULAR_BUF_DESCRIPTOR* QueueDescriptor,
void* objectRef )
{
UINT32 test;
UINT32* testRef;
// Check for valid arguments
if ( QueueDescriptor == NULLPTR || objectRef == NULLPTR ) { return
FAIL; }
// Check to make sure the queue isn't empty first.
if ( IsCbqEmpty(QueueDescriptor) ) { return FAIL; }
test = 0x5555;
testRef = &test;
*testRef = (void *)QueueDescriptor->data[QueueDescriptor->tail++];
// The following line is where I am having the problems... I can get
// the above line to work, but not this one... I am having
indirection
// problems, accoding to Visual C++ v6
*objectRef = (void)QueueDescriptor->data[QueueDescriptor->tail++];
// *objectRef = ((void *)test);
return SUCCESS;
}
[------------Code Ends------------]
So I am not sure what I am doing wrong.. I have tried various
declarations, but none of them work. What am I doing wrong or might be
a better approach? This function is suppose to take care or different
types of data which the application later needs to cast it to the
appropriate data type. Thanks for any help...
Mark
I am having a little problem getting my (void *) assignment to work
correctly. Basically it is some code for a circular queue buffer I am
trying to implement, but getting the deferrencing of the (void *) type
is giving me problems... For brevity sake not all the functions are
defined, but the name gives a clue to what it does...
[------------Code Begins------------]
#define FAIL 0x01
#define SUCCESS 0x00
typedef unsigned long UINT32;
typedef struct {
void* data[CBQ_MAX_QUEUE_SIZE];
INT8 head,
tail;
} CIRCULAR_BUF_DESCRIPTOR;
STATUS_RESULT_TYPE PopCbq( CIRCULAR_BUF_DESCRIPTOR* QueueDescriptor,
void* objectRef )
{
UINT32 test;
UINT32* testRef;
// Check for valid arguments
if ( QueueDescriptor == NULLPTR || objectRef == NULLPTR ) { return
FAIL; }
// Check to make sure the queue isn't empty first.
if ( IsCbqEmpty(QueueDescriptor) ) { return FAIL; }
test = 0x5555;
testRef = &test;
*testRef = (void *)QueueDescriptor->data[QueueDescriptor->tail++];
// The following line is where I am having the problems... I can get
// the above line to work, but not this one... I am having
indirection
// problems, accoding to Visual C++ v6
*objectRef = (void)QueueDescriptor->data[QueueDescriptor->tail++];
// *objectRef = ((void *)test);
return SUCCESS;
}
[------------Code Ends------------]
So I am not sure what I am doing wrong.. I have tried various
declarations, but none of them work. What am I doing wrong or might be
a better approach? This function is suppose to take care or different
types of data which the application later needs to cast it to the
appropriate data type. Thanks for any help...
Mark