expected primary-expression before '.' token

Hi I experienced an error that says "expected primary-expression before '.' token" at this line. May I know what is wrong with this code?

This is where the error is highlighted:

typedef struct DrsPacket { unsigned char ucHeader[2]; unsigned char ucPacketSize; unsigned char ucChipID; unsigned char ucCmd; unsigned char ucCheckSum1; unsigned char ucCheckSum2; DrsData unData; }DrsPacket;

// void hklx_SendPacket(DrsPacket stPacket){ void hklx_SendPacket(DrsPacket stPacket){ unsigned char i; DrsPacket stPacket;

// declare header stPacket.ucHeader[0] = HEADER; stPacket.ucHeader[1] = HEADER;

Thanks!

Hi I experienced an error that says "expected primary-expression before '.' token" at this line.

"This line" implies one line. Not 18 lines.

Where is DrsData defined?

the error is highlighted at these 2 lines actually: 1) stPacket.ucHeader[0] = HEADER; 2) stPacket.ucHeader[1] = HEADER;

DrsData is defined ontop of that 18 lines of code like this:

typedef union DrsData { unsigned char ucData[MAX_PACKET_SIZE-MIN_PACKET_SIZE];

DrsRWData stRWData; DrsIJogData stIJogData; DrsSJogData stSJogData; }DrsData;

I suspect the problem is that the typedef for that struct is in a different file which the compiler is failing to include - but that's only a guess. If you want more than a guess, you need to post all of your code and the actual error message in its entirety.

You seem to be declaring a local variable stPacket with the same name as the function argument. The compiler may not complain about that, but I suggest it's probably not going to result in the behaviour you want.

PeterH is correct. The compiler may be pointing to the two lines that you show, but it is telling you that the problem is that something is expected BEFORE those lines, and that is where you are trying to declare a local variable with the same name as the function argument.