我正在開發一個C++項目,我必須連接到redis數據庫。我試圖讓credis代碼工作,但是當我編譯我得到這些套錯誤讓Credis在C++解決方案中工作
1>c:\c++redis\credis.c(728): warning C4013: 'fcntl' undefined; assuming extern returning int
1>c:\c++redis\credis.c(728): error C2065: 'F_GETFL' : undeclared identifier
1>c:\c++redis\credis.c(729): error C2065: 'F_SETFL' : undeclared identifier
1>c:\c++redis\credis.c(729): error C2065: 'O_NONBLOCK' : undeclared identifier
1>c:\c++redis\credis.c(734): error C2065: 'EINPROGRESS' : undeclared identifier
1>c:\c++redis\credis.c(740): warning C4133: 'function' : incompatible types - from 'int *' to 'char *'
的錯誤是在credis.c
文件從線728至746
/* connect with user specified timeout */
flags = fcntl(fd, F_GETFL);
if ((rc = fcntl(fd, F_SETFL, flags | O_NONBLOCK)) < 0) {
DEBUG("Setting socket non-blocking failed with: %d\n", rc);
}
if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
if (errno != EINPROGRESS)
goto error;
if (cr_selectwritable(fd, timeout) > 0) {
int err;
unsigned int len = sizeof(err);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &len) == -1 || err)
goto error;
}
else /* timeout or select error */
goto error;
}
/* else connect completed immediately */
在哪裏可以我發現這些缺少的類型名稱?
我正在使用visual studio 2010編譯此程序必須在窗口上運行。
我試圖用this建議的答案來批處理代碼,但這並沒有幫助。
@Downvoter爲什麼?爲了讓這個問題更清楚,我需要編輯什麼? – Caesar
什麼是靈魂? – jalf
@jalf修好了,對不起。 – Caesar