user1833570
user1833570

Reputation:

lvalue required as unary '&' operand

Problem while making a call to function as follows:

Function call:

Sbac_DecodeBin(pstSlice->pstBAC,&(UINT8)ui32Abs_Mvd_G_0[0],
pstSlice->pstCtxModel->aucABS_MVD_GREATER_0_1_FLAG,0,
pstSlice->pstValMps->aucABS_MVD_GREATER_0_1_FLAG,BSHandle);

Function declaration:

VOID Sbac_DecodeBin(Init_BAC *pstBAC,UINT8* piBinValue,UINT8* pucSateIdx,
UINT8 CtxInc,UINT8* pucValMPS,HEVCD_BS_HANDLE BSHandle)

The above code doesnt give any compilcation error in Visual c++ 2008 But in linux while creating object file using makefile via gcc -c i get the error:

lvalue required as unary '&' operand 

Can anyone tell me what is the problem?

Upvotes: 1

Views: 7235

Answers (2)

Masked Man
Masked Man

Reputation: 11055

UINT8 is non-standard. I guess it is a specific to the MSVC++ compiler. Try using uint8_t defined in stdint.h instead. Use (uint8_t*)ui32Abs_Mvd_G_0[0] to match the type.

Edit As per discussion in comments below, this should work (UINT8*)ui32Abs_Mvd_G_0[0]

Upvotes: 0

edgar.holleis
edgar.holleis

Reputation: 5001

Change the second argument in the call from &(UINT8)ui32Abs_Mvd_G_0[0]to (UINT8 *)ui32Abs_Mvd_G_0.

The reason for the error message is that you can't take the address of something that isn't an lvalue. A cast from uint32 -> uint8 doesn't qualify. A cast from uint32* to uint8* does.

BTW: You are looking at a potential endianness goof. On little endian you are passing the address of the LSB of the uint32, on big endian you are passing the address of the MSB.

Upvotes: 5

Related Questions