ericmckean / snappy

Automatically exported from code.google.com/p/snappy
Other
0 stars 0 forks source link

Type 'ssize_t' not defined for MSVC builds #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
r77 introduces the use of ssize_t
https://code.google.com/p/snappy/source/detail?r=77

Trying to roll Chromium's version of snappy from 74 to 79 hits this build error:

FAILED: ninja -t msvc -e environment.x86 -- E:\b\build\goma\gomacc.exe 
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe" /nologo 
/showIncludes /FC @obj\third_party\snappy\src\snappy.snappy.obj.rsp /c 
..\..\third_party\snappy\src\snappy.cc 
/Foobj\third_party\snappy\src\snappy.snappy.obj 
/Fdobj\third_party\snappy\snappy.pdb 
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(98) :error 
C2061: syntax error : identifier 'ssize_t'
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(102) :error 
C2065: 'len' : undeclared identifier
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(140) :error 
C2061: syntax error : identifier 'ssize_t'
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(143) :error 
C2065: 'len' : undeclared identifier
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(146) :error 
C2065: 'len' : undeclared identifier
e:\b\build\slave\win\build\src\third_party\snappy\src\snappy.cc(146) : 
fatalerror C1903: unable to recover from previous error(s); stopping compilation

Searching around, it appears as though ssize_t is a POSIX defined type, not 
part of a C++ standard. ptrdiff_t is the approximately equivalent standard type.

Per 
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx 
and looking at other projects, ssize_t can be defined for MSVC builds via:

#include <BaseTsd.h>
typedef SSIZE_T ssize_t;

(I have no preference/recommendation between switching to ptrdiff_t and using 
SSIZE_T, or reverting that part of r77)

Original issue reported on code.google.com by jsbell@chromium.org on 29 Jul 2013 at 10:00

GoogleCodeExporter commented 9 years ago
That last sentence was poorly worded. I was trying to enumerate three distinct 
approaches: (1) switch from ssize_t to ptrdiff_t, (2) use appropriate 
include/typedef of SSIZE_T, or (3) revert part of r77 i.e. switch back from 
ssize_t to int. Again, I have no preference or recommendation.

Original comment by jsbell@chromium.org on 29 Jul 2013 at 10:03

GoogleCodeExporter commented 9 years ago
Hm, breaking MSVC is unfortunate. I'd prefer typedef-ing to SSIZE_T, I guess 
(#3 would revert the performance benefit, and #1 is kind of ugly).

The usual way of doing this would simply be adding AC_TYPE_SSIZE_T to 
configure.ac. However, I guess MSVC doesn't use the autoconf machinery anyway, 
so that wouldn't be too useful for you? I'm reluctant to check for _MSC_VER; 
I'd like to minimize those as much as possible.

Suggestions? What does Chromium do for MSVC+Snappy in general?

Original comment by se...@google.com on 30 Jul 2013 at 9:23

GoogleCodeExporter commented 9 years ago
Chromium has "generated" mac/win/linux versions of snappy-stubs-public.h 
checked into the tree under 
http://src.chromium.org/viewvc/chrome/trunk/src/third_party/snappy/ - they were 
probably autogenerated originally, but are usually hand-tweaked now when the 
.in is updated; I had to do that for r76 (iovec). 

So... modifying configure.ac may be the way to go; I'm not sure how automagical 
it's outputs are but at least we'd have consistent include files between 
platforms.

Original comment by jsbell@chromium.org on 30 Jul 2013 at 6:00

GoogleCodeExporter commented 9 years ago
r80 now contains AC_SIZE_T and AC_SSIZE_T in configure.ac. Thus, marking as 
fixed; you'll still need to make a definition in your manually-maintained 
config.h for MSVC, though.

Original comment by se...@google.com on 13 Aug 2013 at 12:57