Can any one tell what does this below code mean?
I have a macro as follows
#define T_412_A 0xB4C
typedef unsigned long UINT32;
Now i am passing this value to another function as follows:
interface((void *)T_412_A);// 1. what i am sending here either value 0xB4C or address of that
And i am receiving the same in another function as follows and sending the same to another function as follows:
UINT32 interface(void * dynamic_data_vp)//2. what i have received here
{
decode_bit_format((void *)dynamic_data_vp);//what i am sending here address or value
}
decode_bit_format(void * text_data_vp)//what i am receiving here
{
My actual intention is to get the original value 0xB4C here if i am doing anything wrong correct it so that i can get the value here which is 0xB4C
}
This is pure C code answer required ASAP.
Answers (1)
0
1. You're treating 0xB4C as a memory address by casting it to void * i.e. a pointer to an unknown type. So you're sending the address 0xB4C.
2. The interface function is expecting an argument of type void * which is what you're passing it. So you've received the address 0xB4C.
3. The decode_bit_format function is also expecting an argument of type void * which is what you're passing it, though there's no need to cast dynamic_data_vp to void * as it already is one. So again you've received the address 0xB4C.
4. If you want to use 0xB4C as a value rather than an address then you'll need to cast text_data_vp to a suitable integer type.
Accepted