Casting to global variable from LPVOID - C

Posted by Jamie Keeling on Stack Overflow See other posts from Stack Overflow or by Jamie Keeling
Published on 2010-04-20T16:21:26Z Indexed on 2010/04/20 16:23 UTC
Read the original article Hit count: 229

Filed under:
|
|

I am trying to cast data to a struct from a parameter passed into my method, I need the data to be passed to a global variable as it is needed elsewhere in my application.

I have tried the following but I get errors saying that diceResult is an undeclared identifier

Here is the code itself:

//Structure to hold dice data
typedef struct diceData
{
    int dice1;
    int dice2;
};

struct diceResult;

DWORD WINAPI UnpackDiceData(LPVOID sentData)
{
    //Unpack data
    struct diceData unpackedData = *((struct diceData*)sentData);

    diceResult.dice1 = unpackedData.dice1;
    diceResult.dice2 = unpackedData.dice2;
}

I don't understand why it won't recognise it being there when it's clearly global.

© Stack Overflow or respective owner

Related posts about c

    Related posts about struct