void* SendMsg(void* msg) {
char *result;
char tmpBuf[1000]={0};
message send_msg =*(message*)msg;//?
The problem is * and (*)type.
*(message*)"parameterName";
how I can search it? what is that?
"message" is custom made struct.
CodePudding user response:
The code is in C-style whwere a void pointer is passed to the function. To use it it is cast in C-style to message* and immediately dereferenced (in this case assigned to a local variable named send_msg).
This code in C is technically known as a red herring for possible issues.
In C , I would expect a base-class (interface) as parameter or a template parameter.
CodePudding user response:
(message*)msg says "pretend that msg is a pointer to an object of type message. message send_msg = *(message*)msg; says "pretend that msg is a pointer to an object of type message and copy the message object that it points at into send_msg. That will work fine if msg in fact points at an object of type message.
