JavaEar 专注于收集分享传播有价值的技术资料

无法引用默认构造函数 - 它是VS中的已删除函数 (Default constructor cannot be referenced -- It's a deleted function in VS)

I try to compile the code from https://github.com/zcbenz/BPlusTree in Visual Studio 2015 Community. The code can be compiled in gcc, but in VS, I got

the default constructor of "bpt::internal_node_t" cannot be referenced -- it is a deleted function

the structure goes like this:

struct internal_node_t {
    typedef index_t * child_t;

    off_t parent; /* parent node offset */
    off_t next;
    off_t prev;
    size_t n; /* how many children */
    index_t children[BP_ORDER];
}; 

references can be seen everywhere in bpt.cc, like this

internal_node_t parent;

I don't really get what the message means. How to make the code compiled in VS?

some type definition update:

struct key_t {
    char k[16];

    key_t(const char *str = "")
    {
        bzero(k, sizeof(k));
        strcpy_s(k, str);
    }
};
typedef unsigned int     size_t;

struct index_t {
    key_t key;
    off_t child; /* child's offset */
};

I use off_t in <sys\types.h> and a marco #define bzero(ptr, size) memset(ptr, 0, size) for bzero

I also write another program like this:

#include <sys/types.h>
#include <string.h>

#define bzero(ptr, size) memset(ptr, 0, size)

struct key_t {
    char k[16];

    key_t(const char *str = "")
    {
        bzero(k, sizeof(k));
        strcpy_s(k, str);
    }
};
struct index_t {
    key_t key;
    off_t child; /* child's offset */
};



struct internal_node_t {
    typedef index_t * child_t;

    off_t parent; /* parent node offset */
    off_t next;
    off_t prev;
    size_t n; /* how many children */
    index_t children[20];
};

int main() {
    internal_node_t t;
}

That works in VS2015.

1个回答

    最佳答案

  1. 英文原文

    I find it unlikely that a codebase that relies on POSIX types will compile in a compiler that targets Windows. Maybe you should try something like Cygwin.

    For example, both off_t and key_t come from <sys/types.h>. The author didn't even bother including this header, giving a false sense of portability.

    NOTE: VS2015 does have off_t. It seems the actual issue is System V IPC (<sys/ipc.h>, the actual header that cares about key_t) which is linux specific.


    中文翻译

    我发现依赖于POSIX类型的代码库不太可能在针对Windows的编译器中编译。也许你应该尝试像Cygwin这样的东西。

    例如, off_t key_t 都来自&lt; sys / types.h&gt; 。作者甚至不打算包括这个标题,给人一​​种虚假的便携感。

    注意: VS2015 确实有 off_t 。实际问题似乎是System V IPC(&lt; sys / ipc.h&gt; ,关注 key_t 的实际标头),这是特定于Linux的。

    I find it unlikely that a codebase that relies on POSIX types will compile in a compiler that targets Windows. Maybe you should try something like Cygwin.

    For example, both off_t and key_t come from <sys/types.h>. The author didn't even bother including this header, giving a false sense of portability.

    NOTE: VS2015 does have off_t. It seems the actual issue is System V IPC (<sys/ipc.h>, the actual header that cares about key_t) which is linux specific.

    我发现依赖于POSIX类型的代码库不太可能在针对Windows的编译器中编译。也许你应该尝试像Cygwin这样的东西。

    例如, off_t key_t 都来自&lt; sys / types.h&gt; 。作者甚至不打算包括这个标题,给人一​​种虚假的便携感。

    注意: VS2015 确实有 off_t 。实际问题似乎是System V IPC(&lt; sys / ipc.h&gt; ,关注 key_t 的实际标头),这是特定于Linux的。