Re: [libuv] Help needed with Windows ssize_t error from uv-win.h

436 views
Skip to first unread message

Ben Noordhuis

unread,
Mar 2, 2013, 7:55:07 AM3/2/13
to li...@googlegroups.com
On Sat, Mar 2, 2013 at 7:39 AM, Rod Vagg <r...@vagg.org> wrote:
>
> I'm (slowly) trying to get a libuv-based port of LevelDB going so people can
> use it on Windows with Node. Code is here in the libuv-port branch:
> https://github.com/rvagg/leveldb
>
> My current hiccup is an odd one. By way of a few header files (particularly
> port_uv.h), uv.h should be included on each compilation unit and mostly I
> don't get any errors or even warnings. But then it comes to port_uv.cc,
> which really doesn't do anything special and certainly doesn't include any
> odd, extra header files itself I suddenly get this error about the ssize_t
> declaration in uv-win.h:
>
> port_uv.cc
> c:\users\rvagg\documents\github\leveldb\libuv\include\uv-private/uv-win.h(27):
> error C2146: syntax error : missing ';' before identifier 'ssize_t'
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> c:\users\rvagg\documents\github\leveldb\libuv\include\uv-private/uv-win.h(27):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> c:\users\rvagg\documents\github\leveldb\libuv\include\uv-private/uv-win.h(27):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(322): error
> C2061: syntax error : identifier 'ssize_t'
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(329): error
> C2061: syntax error : identifier 'ssize_t'
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(733): error
> C2061: syntax error : identifier 'ssize_t'
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(1518): error
> C2146: syntax error : missing ';' before identifier 'result'
> [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(1518): error
> C4430: missing type specifier - int assumed. Note: C++ does not support
> default-int [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
> C:\Users\rvagg\Documents\GitHub\leveldb\libuv\include\uv.h(1518): error
> C4430: missing type specifier - int assumed. Note: C++ does not support
> default-int [C:\Users\rvagg\Documents\GitHub\leveldb\leveldb.vcxproj]
>
> fyi, MSVS 10.0, and:
>
> > MSBuild.exe /version
> Microsoft (R) Build Engine Version 4.0.30319.1
> [Microsoft .NET Framework, Version 4.0.30319.296]
>
> Which I guess looks like there's a stray macro rewriting this:
>
> typedef intptr_t ssize_t;
>
> But I have no idea what it could be!
>
> Has anyone seen anything like this before or have suggestions on where to go
> hunting to sort this out?
>
> Cheers,
> -- Rod

Perhaps related to https://github.com/joyent/libuv/issues/702 ?

Rod Vagg

unread,
Mar 2, 2013, 7:28:42 PM3/2/13
to li...@googlegroups.com

I looked over #702 before I posted here but I don't think it's related to my problem. It seems to be a problem with the actual typedef and not the macros around it. If I remove all of the macro cruft then I still get the error.

Rod Vagg

unread,
Mar 2, 2013, 7:44:23 PM3/2/13
to li...@googlegroups.com

I've just produced a preprocessor output and it still has the original, unmangled "typedef intptr_t ssize_t;" so I'm even more lost now.

Bert Belder

unread,
Mar 4, 2013, 10:53:57 AM3/4/13
to li...@googlegroups.com
Leveldb ships with a "replacement" stdint.h (https://github.com/rvagg/leveldb/blob/libuv-port/port/win/stdint.h) which is only added to the include search path on windows. This replacement is incomplete (e.g. lacks a definition for intptr_t) which causes your problem.

There is some sense in polyfilling stdint.h on windows, because the one that shipped with VS 2008 was no good. Libuv takes care of this. If you need it in other places, I suggest you use the same polyfill version as libuv uses, https://github.com/joyent/libuv/blob/master/include/uv-private/stdint-msvc2008.h.

- Bert

Rod Vagg

unread,
Mar 5, 2013, 6:40:47 AM3/5/13
to li...@googlegroups.com

Excellent! Thanks so much for the help Bert. I'm without my Windows dev machine for a week so I won't be tinkering with this till I get it back. I'm pretty sure I wasn't using the stdint.h bundled with leveldb; but the lack of a definition, with or without the win/stdint.h would put this error into context I guess!
Cheers,
 -- Rod

Bert Belder

unread,
Mar 5, 2013, 6:49:24 AM3/5/13
to li...@googlegroups.com
> I'm pretty sure I wasn't using the stdint.h bundled with leveldb;

I checked out out your source code and I'm 100% positive this file got included. You probably didn't do it deliberately though - your project setup just adds the directory to the include search path, and libuv actually does the actual `#include <stdint.h>`.

Good luck with your porting efforts. I'm happy that you're doing this, good across-the-board leveldb support seems like a definite win for the node community to me.

- Bert

Ryan Dahl

unread,
Mar 12, 2013, 1:27:30 AM3/12/13
to li...@googlegroups.com
Isn't leveldb already working on windows out of the box?

Rod Vagg

unread,
Mar 13, 2013, 6:51:34 PM3/13/13
to li...@googlegroups.com, r...@tinyclouds.org


On Tuesday, 12 March 2013 16:27:30 UTC+11, Ryan Dahl wrote:
Isn't leveldb already working on windows out of the box?

Not quite. In Chromium it hooks into the internal environment to provide the cross-platform things it needs. As a stand-alone library it's only built for posix with some very half-hearted fluff for Windows (as if they began a port but never bothered to finish it). There are ports available that depend on Boost but I'd rather not hoist such a large dependency on Node users when we have libuv at our disposal.

Do you feel like helping Ryan? It really shouldn't be that difficult to complete, I just need to find the time. There's only the bits in env.cc (see posix version) that need finishing to get this going.

 -- Rod

Rod Vagg

unread,
Apr 7, 2013, 10:33:40 PM4/7/13
to li...@googlegroups.com

FYI we now have LevelDB for Node compiling in Windows. Leve...@0.2.0 (http://npm.im/leveldown) includes a partial Libuv port, plus a bunch of Windows-specific code. Over time I hope to consolidate it to mostly rely on Libuv but for now it's working so that's the important bit. Lev...@0.7.0 (http://npm.im/levelup) is the main client-lib that people ought to use for LevelDB in Node.

Now we just need to be able to do pre-compiled binary distributables nicely with npm...

Rod

Reply all
Reply to author
Forward
0 new messages