多线程和得到一个错误调用函数

Multi threading and getting An Error Calling Function

本文关键字:一个 错误 调用 函数 多线程      更新时间:2023-10-16

使用Microsoft Kinect VS 2013编写多线程代码。

char fnameC[sizeof "C:\Users\Adam\Desktop\Skeleton_RGBDepth_DataAcquisition2013\Skeleton_RGBDepth_DataAcquisition2013\Color_Image\Color_01_c1_00_00_000.png"];
char fnameD[sizeof "C:\Users\Adam\Desktop\Skeleton_RGBDepth_DataAcquisition2013\Skeleton_RGBDepth_DataAcquisition2013\Depth_Image\Depth_01_c1_00_00_000.png"];
int main() {
 set up stuff....
 while(1) {
    setup of the color image frame and depth image frame...
    std::thread im01(cv::imwrite, std::ref(fnameC), std::ref(colorImage));
    std::thread im02(cv::imwrite, std::ref(fnameD), std::ref(depthImage));
    im01.join();
    im02.join();

}
}

我得到一个错误:

错误1错误C2090:函数返回数组c:program files (x86)microsoft visual studio 12.0vcincludexrefwrap 432 1 specialon_rgbdepth_dataacquisition 2013

不太确定发生了什么…需要帮助,谢谢;我想要一个!

这可能是VS中的一个缺陷,因为引用包装器应该只返回.get()上的引用或通过operator T&的隐式强制转换,因此不应该触发此错误。请注意,您的问题在g++ 4.8.2中无法重现。但是,如果您丢弃引用包装器,应该没有问题。

无论哪种方式,cv::imwrite期望const std::string&,而不是char (&)[136]。无论如何,使用std::string是更好的方法,所以这将是研究它们的好时机。

C2090 is Compiler Error C2090:

A function cannot return an array. Return a pointer to an array instead.
The following sample generates C2090:
// C2090.cpp
int func1(void)[] {}   // C2090

你在xrefwrap:432中击中了这个。这是由std::ref(fnameC)char fnameC[...]的定义引起的。结果std::reference_wrapper<char[]>.Get()应该返回char[],因此出现错误。

p。对路径缓冲区使用MAX_PATH。对字符串使用std::string

相关文章: