I have a function declaration
int checkWinsockError(int errorCode, const char *errorType, bool getError, int WSAAPI cleanupFunc(), struct addrinfo *addrToFree, SOCKET *socketToClose, bool sockError);
and a function definition.
int checkWinsockError(int errorCode, const char *errorType, bool getError=false, int WSAAPI cleanupFunc()=nullptr, struct addrinfo *addrToFree=nullptr, SOCKET *socketToClose=nullptr, bool sockError=false) {
// error handling code
}
When I make a call to this function,
checkWinsockError(10000, "error");
I get the error ''checkWinsockError': function does not take 2 arguments'. This call to the function
checkWinsockError(10000, "error", false);
overriding the first default argument gives the error ''checkWinsockError': function does not take 3 arguments'. This continues until I override the last default argument, sockError, with a function call like this.
checkWinsockError(10000, "error", false, nullptr, nullptr, nullptr, false);
I only began experiencing this error after adding sockError to the list of parameters. Why does the compiler force me to pass a value for this parameter when there is a default argument? I am using Visual Studio 2017 and the Winsock library.