Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSVC compile issue related with ssize_t #2027

Merged
merged 2 commits into from
Oct 14, 2017

Conversation

denix56
Copy link
Contributor

@denix56 denix56 commented Oct 14, 2017

The issue is caused because in MSVC the gnu ssize_t type is called SSIZE_T

Maintainer edit: Fixes #2023.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Oct 14, 2017

I ran a quick find through pcl and this type is only used in the Dinast Grabber cpp file, while using a libusb function, and as expected, they export that type. See http://libusb.sourceforge.net/api-1.0/libusb_8h_source.html line 36 onwards. So what exactly is happening in your case?

@denix56
Copy link
Contributor Author

denix56 commented Oct 14, 2017

msvc throws error while compiling pcd_io.cpp
look somewhere near line 770:

ssize_t num_read = pcl_read (fd, &compressed_size, 4);

hear is the use of ssize_t

@SergioRAgostinho
Copy link
Member

It was introduced on a fairly recent merge. So I would prefer to follow what both MingW and libusb do and copy the snippet below here https://github.com/PointCloudLibrary/pcl/blob/master/io/src/pcd_io.cpp#L59, on the Windows related conditional branch.

/* ssize_t is also not available (copy/paste from MinGW) */
#ifndef _SSIZE_T_DEFINED
#define _SSIZE_T_DEFINED
#undef ssize_t
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef int ssize_t;
#endif /* _WIN64 */
#endif /* _SSIZE_T_DEFINED */
#endif /* _MSC_VER */

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Oct 14, 2017

That line seems to be included in since release PCL 1.8.1. (PR #1986)
Probably, It is affects all versions of Visual C++.
I think that it is necessary resolve this problem.

@SergioRAgostinho
Copy link
Member

Scrap what I just said, copy the snippet here https://github.com/PointCloudLibrary/pcl/blob/master/io/include/pcl/io/impl/pcd_io.hpp#L63 . It has to go there because that's where we're exporting this pcl_read definition which is always accessible if you include the header.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UnaNancyOwen Please double check this is compiling and passing the io tests. For the merge, please squash keeping only the commit message from the first commit.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Oct 14, 2017

@SergioRAgostinho It can be built successfully. But, test failed.
(However, I don't know whether this test has failed since before on Windows.)

> .\test_grabbers.exe "../../test/grabber_sequences"
added: ../../test/grabber_sequences/pcd\frame_20121214T142255.814212.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.068683.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.332395.pcd
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from PCL
[ RUN      ] PCL.PCDGrabber
C:\pcl-FixMSVCTypeIssue\test\io\test_grabbers.cpp(56): error:       Expected: pcds_.size ()
      Which is: 3
To be equal to: grabbed_clouds.size ()
      Which is: 1
[  FAILED  ] PCL.PCDGrabber (3319 ms)
[ RUN      ] PCL.ImageGrabberTIFF
[       OK ] PCL.ImageGrabberTIFF (5562 ms)
[ RUN      ] PCL.ImageGrabberPCLZF
[       OK ] PCL.ImageGrabberPCLZF (5558 ms)
[ RUN      ] PCL.ImageGrabberOMP
User Error 1001: argument to num_threads clause must be positive
User Error 1001: argument to num_threads clause must be positive
User Error 1001: argument to num_threads clause must be positive
User Error 1001: argument to num_threads clause must be positive
User Error 1001: argument to num_threads clause must be positive
User Error 1001: argument to num_threads clause must be positive
[       OK ] PCL.ImageGrabberOMP (4798 ms)
[ RUN      ] PCL.ImageGrabberTimestamps
[       OK ] PCL.ImageGrabberTimestamps (8 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsTIFF
[       OK ] PCL.ImageGrabberSetIntrinsicsTIFF (2494 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsPCLZF
[       OK ] PCL.ImageGrabberSetIntrinsicsPCLZF (2413 ms)
[----------] 7 tests from PCL (24168 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (24169 ms total)
[  PASSED  ] 6 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] PCL.PCDGrabber

 1 FAILED TEST

Note: test_grabbers result of pcl-1.8.1 tag

> .\test_grabbers.exe "../../test/grabber_sequences"
added: ../../test/grabber_sequences/pcd\frame_20121214T142255.814212.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.068683.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.332395.pcd
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from PCL
[ RUN      ] PCL.PCDGrabber
[       OK ] PCL.PCDGrabber (1245 ms)
[ RUN      ] PCL.ImageGrabberTIFF
[       OK ] PCL.ImageGrabberTIFF (281 ms)
[ RUN      ] PCL.ImageGrabberPCLZF
[       OK ] PCL.ImageGrabberPCLZF (246 ms)
[ RUN      ] PCL.ImageGrabberOMP
[       OK ] PCL.ImageGrabberOMP (281 ms)
[ RUN      ] PCL.ImageGrabberTimestamps
[       OK ] PCL.ImageGrabberTimestamps (0 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsTIFF
[       OK ] PCL.ImageGrabberSetIntrinsicsTIFF (175 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsPCLZF
[       OK ] PCL.ImageGrabberSetIntrinsicsPCLZF (142 ms)
[----------] 7 tests from PCL (2375 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (2376 ms total)
[  PASSED  ] 7 tests.

@denix56
Copy link
Contributor Author

denix56 commented Oct 14, 2017

It is strange. I ran that test too on Visual Studio 2017:

added: D:\dev-tools\pcl\test\grabber_sequences/pcd\frame_20121214T142255.814212.pcd
added: D:\dev-tools\pcl\test\grabber_sequences/pcd\frame_20121214T142256.068683.pcd
added: D:\dev-tools\pcl\test\grabber_sequences/pcd\frame_20121214T142256.332395.pcd
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from PCL
[ RUN      ] PCL.PCDGrabber
[       OK ] PCL.PCDGrabber (1339 ms)
[ RUN      ] PCL.ImageGrabberTIFF
[       OK ] PCL.ImageGrabberTIFF (540 ms)
[ RUN      ] PCL.ImageGrabberPCLZF
[       OK ] PCL.ImageGrabberPCLZF (355 ms)
[ RUN      ] PCL.ImageGrabberOMP
[       OK ] PCL.ImageGrabberOMP (314 ms)
[ RUN      ] PCL.ImageGrabberTimestamps
[       OK ] PCL.ImageGrabberTimestamps (0 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsTIFF
[       OK ] PCL.ImageGrabberSetIntrinsicsTIFF (221 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsPCLZF
[       OK ] PCL.ImageGrabberSetIntrinsicsPCLZF (173 ms)
[----------] 7 tests from PCL (2945 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (2946 ms total)
[  PASSED  ] 7 tests.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Oct 14, 2017

@denix56 What do you use updated version of Visual Studio 2017? What is version numbers of x? (15.x)
You can confirm it with [Help]>[About Microsoft Visual Studio] in Visual Studio.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Oct 14, 2017

@denix56 @SergioRAgostinho Sorry, I tried test again. It all succeeded. I think ready to merge this pull request. Thanks,

> .\test_grabbers.exe "../../test/grabber_sequences"
added: ../../test/grabber_sequences/pcd\frame_20121214T142255.814212.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.068683.pcd
added: ../../test/grabber_sequences/pcd\frame_20121214T142256.332395.pcd
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from PCL
[ RUN      ] PCL.PCDGrabber
[       OK ] PCL.PCDGrabber (1293 ms)
[ RUN      ] PCL.ImageGrabberTIFF
[       OK ] PCL.ImageGrabberTIFF (649 ms)
[ RUN      ] PCL.ImageGrabberPCLZF
[       OK ] PCL.ImageGrabberPCLZF (258 ms)
[ RUN      ] PCL.ImageGrabberOMP
[       OK ] PCL.ImageGrabberOMP (1041 ms)
[ RUN      ] PCL.ImageGrabberTimestamps
[       OK ] PCL.ImageGrabberTimestamps (1 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsTIFF
[       OK ] PCL.ImageGrabberSetIntrinsicsTIFF (182 ms)
[ RUN      ] PCL.ImageGrabberSetIntrinsicsPCLZF
[       OK ] PCL.ImageGrabberSetIntrinsicsPCLZF (163 ms)
[----------] 7 tests from PCL (3593 ms total)

[----------] Global test environment tear-down
[==========] 7 tests from 1 test case ran. (3595 ms total)
[  PASSED  ] 7 tests.

@SergioRAgostinho SergioRAgostinho merged commit f4d6203 into PointCloudLibrary:master Oct 14, 2017
@denix56 denix56 deleted the FixMSVCTypeIssue branch October 15, 2017 07:23
@taketwo taketwo added this to the pcl-1.9.0 milestone Oct 16, 2017
UnaNancyOwen pushed a commit to UnaNancyOwen/pcl that referenced this pull request Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants