I understand that startup_info is a pointer to a STARTUPINFO structure
I have a function which I pass startup_info by reference into it. So we can say that I am passing a pointer by reference
void cp(....., LPSTARTUPINFO & startup_info) {
CreateProcessW(....., startup_info);
}
Let us assume that I call function cp in this function caller()
void caller() {
STARTUPINFO startup_info;
cp(....., startup_info); // error occurs here, I cannot convert 'STARTUPINFO' to 'LPSTARTUPINFO &'
}
It will give me error message: Error in CreateProcessW: cannot convert parameter 9 from ‘STARTUPINFO’ to ‘LPSTARTUPINFO &’
But since statup_info is a pointer, I should be able to pass this into function cp right?
EDIT:
Thank you for your advices,but the following works for me:
LPSTARTUPINFO is a pointer to STARTUPINFO structure
So I change to
void cp(....., LPSTARTUPINFO startup_info_ptr) {
CreateProcessW(....., startup_info_ptr); // pass in pointer of startup_info
}
void caller() {
STARTUPINFO startup_info;
cp(....., &startup_info); // passing the address of startup_info
}
You’ve got two
startup_info‘s. Incaller(), it’s aSTARTUPINFO(not a pointer). Incp(), it’s aSTARTUPINFO*&(reference to a pointer). Why? It’s most likely unintentional.I’d expect:
In production code, I avoid
pprefixes for pointers but I’ve used it here to disambiguate the twostartup_info‘s which you had.