SLAM十四讲 ch7 orb_self.cpp中402行代码:cv::DMatch m{i1, 0, 256}报错

orb_self.cpp中402行代码:cv::DMatch m{i, 0, 256};

报错:warning: narrowing conversion of ‘i’ from ‘size_t {aka long unsigned int}’ to ‘int’ inside { } [-Wnarrowing]
解决:
size_t和int的区别:size_t是一些C/C++标准在stddef.h中定义的,其的真实类型与操作系统有关。(在32位架构中被普遍定义为:typedef unsigned int size_t;在64位架构中被定义为:typedef unsigned long size_t;)。即 size_t在32位架构上是4字节,在64位架构上是8字节;而int在不同架构下都是4字节。进行强制类型转换,将变量 i 强制转换为int型。

猜你喜欢

转载自blog.csdn.net/qq_45577269/article/details/126784959