简体   繁体   中英

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?

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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM