[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Compiling LMDB with Visual C++

Quanah wrote:
> Latest is 0.9.17.

Thanks. Where's the howto or link to fetch that?

Howard wrote:
You're welcome to submit code patches against the latest code
> in mdb.master. MSVC Project files and other such stuff
will not be accepted

Ok, thanks. How about cmake? Would you like that?

I created a set of small C++ wrapper classes to make the API easier to use in C++ applications. Would you like that?

Timur wrote:
> I'd be interested to see those code changes.

Ok, I'll make a patch after I sync up with 0.9.17 and confirm it still builds on Linux.

For the most part, the code changes I made were adding explicit void* casts, which C++ is more strict about than C. I still have these VC++ warnings (in 0.9.15) that I didn't fix:

1>c:\code\lib\liblmdb\mdb.c(3892): warning C4244: '=' : conversion from 'LONGLONG' to 'size_t', possible loss of data 1>c:\code\lib\liblmdb\mdb.c(4287): warning C4244: 'argument' : conversion from 'mdb_hash_t' to 'unsigned long', possible loss of data 1>c:\code\lib\liblmdb\mdb.c(6458): warning C4146: unary minus operator applied to unsigned type, result still unsigned 1>c:\code\lib\liblmdb\mdb.c(8859): warning C4804: '>>' : unsafe use of type 'bool' in operation 1>c:\code\lib\liblmdb\mdb.c(8860): warning C4804: '>>' : unsafe use of type 'bool' in operation

I can make these warnings go away with casts. Should I? Do any of these seem like they may be bugs?

One bug I noticed, I encountered a segfault when opening a directory that didn't exist and so make this change to mdb.c:

    /* For RDONLY, get lockfile after we know datafile exists */
    if (!(flags & (MDB_RDONLY|MDB_NOLOCK))) {
        rc = mdb_env_setup_locks(env, lpath, mode, &excl);
#ifndef _MSC_VER
        if (rc)
            goto leave;

The goto skips over allocating to a null pointer that is dereferenced later, thus triggering a null pointer segfault.