[英]I´m trying use make on windows but its giving error
I´m trying to make this project https://github.com/Slamtec/rplidar_sdk .我正在尝试制作这个项目https://github.com/Slamtec/rplidar_sdk 。 But when i run the make command i get the following error:但是当我运行 make 命令时,我收到以下错误:
In file included from src/sl_lidar_driver.cpp:40:
src/hal/event.h: In member function 'long unsigned int rp::hal::Event::wait(long unsigned int)':
src/hal/event.h:108:20: warning: conversion from 'rp::hal::Event::<unnamed enum>' to 'long unsigned int' changes value from 'rp::hal::Event::EVENT_TIMEOUT' to '4294967295' [-Woverflow]
108 | return EVENT_TIMEOUT;
| ^~~~~~~~~~~~~
src/sl_lidar_driver.cpp: In member function 'virtual sl_result sl::SlamtecLidarDriver::grabScanDataHq(sl_lidar_response_measurement_node_hq_t*, size_t&, sl_u32)':
src/sl_lidar_driver.cpp:556:34: error: narrowing conversion of 'rp::hal::Event::EVENT_TIMEOUT' from 'long long unsigned int' to 'long unsigned int' [-Wnarrowing]
556 | case rp::hal::Event::EVENT_TIMEOUT:
| ^~~~~~~~~~~~~
src/sl_lidar_driver.cpp:556:13: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' [-Woverflow]
556 | case rp::hal::Event::EVENT_TIMEOUT:
| ^~~~
src/sl_lidar_driver.cpp: In member function 'sl_result sl::SlamtecLidarDriver::_sendCommand(sl_u16, const void*, size_t)':
src/sl_lidar_driver.cpp:1089:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<unsigned char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
1089 | for (int pos = 0; pos < cmd_packet.size(); pos++) {
| ~~~~^~~~~~~~~~~~~~~~~~~
src/sl_lidar_driver.cpp:1058:19: warning: unused variable 'pkt_header' [-Wunused-variable]
1058 | sl_u8 pkt_header[10];
| ^~~~~~~~~~
src/sl_lidar_driver.cpp: In member function 'void sl::SlamtecLidarDriver::_ultraCapsuleToNormal(const sl_lidar_response_ultra_capsule_measurement_nodes_t&, sl_lidar_response_measurement_node_hq_t*, size_t&)':
src/sl_lidar_driver.cpp:1370:40: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
1370 | if ((dist_predict1 == 0xFFFFFE00) || (dist_predict1 == 0x1FF)) {
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
src/sl_lidar_driver.cpp:1379:40: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
1379 | if ((dist_predict2 == 0xFFFFFE00) || (dist_predict2 == 0x1FF)) {
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~
src/sl_lidar_driver.cpp: At global scope:
src/sl_lidar_driver.cpp:72:17: warning: 'void sl::convert(const sl_lidar_response_measurement_node_hq_t&, sl_lidar_response_measurement_node_t&)' defined but not used [-Wunused-function]
72 | static void convert(const sl_lidar_response_measurement_node_hq_t& from, sl_lidar_response_measurement_node_t& to)
| ^~~~~~~
src/sl_lidar_driver.cpp:59:17: warning: 'void sl::printDeprecationWarn(const char*, const char*)' defined but not used [-Wunused-function]
59 | static void printDeprecationWarn(const char* fn, const char* replacement)
make[1]: *** [/c/rplidar_sdk/mak_common.inc:82: /c/rplidar_sdk/obj/MSYS_NT-10.0-19044/Release/sdk/src/sl_lidar_driver.o] Error 1
make[1]: Leaving directory '/c/rplidar_sdk/sdk'
make: *** [/c/rplidar_sdk/mak_common.inc:43: make_subs] Error 1
someone could tell me why i getting this error and how to solved it?有人可以告诉我为什么我会收到这个错误以及如何解决它?
Apparently this code is not portable.显然这段代码是不可移植的。
It appears to assume that a long int
is 64bits (8 bytes) long, which is true on Linux and MacOS.似乎假设long int
的长度为 64 位(8 字节),这在 Linux 和 MacOS 上是正确的。 But on Windows, a long int
is only 32bits (4 bytes) long.但是在 Windows 上, long int
只有 32 位(4 字节)长。
C and C++ have 5 integral types (ignoring the unsigned versions): char
, short
, int
, long
, long long
. C 和 C++ 有 5 种整数类型(忽略无符号版本): char
、 short
、 int
、 long
、 long long
。 The C standard gives a minimum range of integers that must fit into these types, but it doesn't give a maximum . C 标准给出了必须适合这些类型的最小整数范围,但没有给出最大值。 It's up to the implementation.这取决于实施。 See https://en.wikipedia.org/wiki/C_data_types#Main_types见https://en.wikipedia.org/wiki/C_data_types#Main_types
A modern system has native support for 4 sizes of integer: 1 byte, 2 bytes, 4 bytes, 8 bytes.现代系统原生支持 4 种大小的 integer:1 字节、2 字节、4 字节、8 字节。
So you can see that in order to map 5 types onto 4 sizes, two of the types must map to the same size.所以你可以看到,为了将 map 5 种类型转换为 4 种尺寸,其中两种类型必须 map 为相同的尺寸。
Linux and MacOS choose to have int
be 4 bytes and long
and long long
both be 8 bytes. Linux 和 MacOS 选择int
为 4 字节, long
和long long
均为 8 字节。 Windows chooses to have int
and long
both be 4 bytes, and long long
be 8 bytes. Windows 选择int
和long
均为 4 字节, long long
为 8 字节。 See https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models请参阅https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
If the code is written to assume that long
and long long
are the same size and can be used interchangeably, then you'll get errors like the ones you're seeing when you try to compile it on Windows.如果编写代码时假定long
和long long
的大小相同并且可以互换使用,那么您将得到类似于在 Windows 上编译时所看到的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.