Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C , Error: Expression must be a modifiable lvalue

i have the following code:

#define NULL ((void*)0)
void* Globalptr = NULL;
void func(ptrtype* input)
{
 ((ptrtype*)Globalptr) = input;
}

I get Error on line ((ptrtype*)Globalptr) = input; says " expression must be a modifiable lvalue"

like image 795
Islam Wahdan Avatar asked Oct 30 '25 11:10

Islam Wahdan


1 Answers

You must make the data to match the variable (lvalue), and not change the type of the variable to match the data:

Globalptr = (void*)input;

But since you can convert any data pointer to void* in C, you can simply do:

Globalptr = input;
like image 102
user694733 Avatar answered Nov 02 '25 00:11

user694733



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!