家伙! 我在编译项目时遇到错误
LoadConnectorModule.cpp:59:72: error: no matching function for call to ‘LoadConnectorModule::generateFileFoundResponse(char*&, int&, char ( * )[1024], int&)’
generateFileFoundResponse(dataBuffer, dataLength, &fileName, fd);
^
LoadConnectorModule.cpp:59:72: note: candidate is:
In file included from LoadConnectorModule.cpp:1:0:
LoadConnectorModule.h:16:10: note: void LoadConnectorModule::generateFileFoundResponse(char*, int, char*, int)
void generateFileFoundResponse(char* dataBuffer, int dataLength, char *fileName, int fd);
此处调用函数generateFileFoundResponse
char * dataBuffer = NULL;
char fileName[Utils::default_message_size];
int dataLength;
generateFileFoundResponse(dataBuffer, dataLength, &fileName, fd);
并声明为
void generateFileFoundResponse(char* dataBuffer, int dataLength, char *fileName, int fd);
此类中的所有其他方法都存在相同的错误。你有什么想法,如何解决这个问题?
答案 0 :(得分:1)
fileName
参数是char*
,但您传递char (*) [1024]
(指向数组的指针)。只需传递数组本身,让它衰减到一个指针:
generateFileFoundResponse(dataBuffer, dataLength, fileName, fd);
// ^ no &