c++ - 没有匹配的调用函数 (type&)

标签 c++ compiler-errors

伙计们! 编译项目时出错

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);

并且该类中的所有其他方法都存在相同的错误。你有什么idea,如何解决这个问题?

最佳答案

fileName 参数是一个char*,但是您传递了一个char (*) [1024](指向数组的指针)。只需传递数组本身并让它衰减为指针:

generateFileFoundResponse(dataBuffer, dataLength, fileName, fd);
//                                                ^ no &

关于c++ - 没有匹配的调用函数 (type&),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34850398/

相关文章:

c++ - C++ 中的错误消息 "Undefined reference error to"

ios - Xcode 6上的Swift编译器错误

java - 使用Junit的三角测试: void type is not allowed

c++ - GCC-Visual Studio std::thread 编译器差异

c++ - UI 自动化回调中 COM 对象的所有权

c++ - 当存在空单元格时,C++ 的 Tsv 文件解析器突然结束

c# - 解析 XAML : "Integer types not allowed" errors for many attributes such as width 时出错

java - 编译错误尝试修复,没有成功

c++ - Python ImportError - undefined symbol - 用于自定义 C++ 模块

javascript - QWebEngineView 中未定义的 qt.webChannelTransport