【问题标题】:Multi threading and getting An Error Calling Function多线程并获取错误调用函数
【发布时间】:2014-08-07 07:56:18
【问题描述】:

使用 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.0\vc\include\xrefwrap 432 1 Skeleton_RGBDepth_DataAcquisition2013

不太确定发生了什么...需要帮助,谢谢;会喜欢的!

【问题讨论】:

    标签: c++ multithreading visual-c++ file-io


    【解决方案1】:

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

    无论哪种方式,cv::imwrite 都需要 const std::string&,而不是 char (&)[136]。无论如何,与std::strings 合作会更好,所以现在是研究它们的好时机。

    【讨论】:

      【解决方案2】:

      C2090Compiler 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[],因此会出现错误。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-03
        • 2023-03-04
        • 2022-10-06
        • 2012-11-19
        • 2015-02-20
        相关资源
        最近更新 更多