728x90
[C/C++] 소켓에서 컴파일 에러 (invalid conversion from int* to socklen_t*)
증상
: 소켓 프로그래밍에서 gcc / g++ 컴파일 시 아래와 같이 에러가 발생될 경우
error: invalid conversion from int* to socklen_t*
해결 방안 1
: 자료형 선언을 변경한다. int 대신에 socklen_t로 변경
// Define clientLen as socklen_t:
socklen_t clientLen;
// instead of
int clientLen;
해결 방안 2
: (socklen_t*) 앞에 붙여 자료형을 맞춘다.
int clientLen = 0;
// Change
clientFd = accept (serverFd, clientSockAddrPtr, &clientLen);
// to
clientFd = accept (serverFd, clientSockAddrPtr,(socklen_t*)&clientLen);
반응형
'Programming > C, C++' 카테고리의 다른 글
[C++, Error] (centos) cannot find -lstdc++ (0) | 2020.06.24 |
---|---|
[Linux, C/C++] undefined reference to '__gxx_personality_v0' 오류 조치 (0) | 2020.04.09 |
[C, Error] error: use of undeclared identifier '함수' (0) | 2020.04.09 |
[C++, Error] unresolved overloaded function type (0) | 2019.07.22 |
[Linux,C++] getenv.c: undefined reference secure_getenv (0) | 2019.03.29 |