Hal Finney 通信

回复:磁盘已满(编译器与 serialize.h 修正)

中本聪 · 2009 年 1 月 24 日 · 16:47(原件未注明时区)

SN-10231 附来源、原文与上下文。

阅读语言

我讨厌重复代码,但编译器逼得我们没办法。把它上面那个函数的函数体复制过来,像这样:

I hate duplicating code, but the compiler forces us. Copy the body of the function above it, like this:

    void insert(iterator it, const_iterator first, const_iterator last)
    {
        if (it == vch.begin() + nReadPos && last - first <= nReadPos)
        {
            // special case for inserting at the front when there's room
            nReadPos -= (last - first);
            memcpy(&vch[nReadPos], &first[0], last - first);
        }
        else
            vch.insert(it, first, last);
    }

#if !defined(_MSC_VER) || _MSC_VER >= 1300
    void insert(iterator it, const char* first, const char* last)
    {
        if (it == vch.begin() + nReadPos && last - first <= nReadPos)
        {
            // special case for inserting at the front when there's room
            nReadPos -= (last - first);
            memcpy(&vch[nReadPos], &first[0], last - first);
        }
        else
            vch.insert(it, first, last);
    }
#endif
    void insert(iterator it, const_iterator first, const_iterator last)
    {
        if (it == vch.begin() + nReadPos && last - first <= nReadPos)
        {
            // special case for inserting at the front when there's room
            nReadPos -= (last - first);
            memcpy(&vch[nReadPos], &first[0], last - first);
        }
        else
            vch.insert(it, first, last);
    }

#if !defined(_MSC_VER) || _MSC_VER >= 1300
    void insert(iterator it, const char* first, const char* last)
    {
        if (it == vch.begin() + nReadPos && last - first <= nReadPos)
        {
            // special case for inserting at the front when there's room
            nReadPos -= (last - first);
            memcpy(&vch[nReadPos], &first[0], last - first);
        }
        else
            vch.insert(it, first, last);
    }
#endif

随信附上了修改后的 serialize.h。

The modified version of serialize.h is attached.

顺便说一句,在我的测试中,VC8 生成的 EXE 只能在安装了 VC8 的系统上运行。它给出的错误提示极其含糊。我想,他们是希望你在安装时再安装一个软件包,但 bitcoin 没有安装程序。

BTW, in my tests, VC8 produced an EXE that would only run on systems that had VC8 installed on them. The error it gives is extremely vague. I think they expect you to install a package during setup, but bitcoin doesn't have a setup.

我一直使用 MSVC 6.0 SP6 和 GCC 3.4.5 做测试。正式发布版是用 GCC 编译的。MSVC 6.0 编译出来的版本没什么别的问题,只是它优化后的 SHA 例程在生成区块时运行得慢。

My testing has been with MSVC 6.0 SP6 and GCC 3.4.5. GCC is the release build. There's nothing wrong with the MSVC 6.0 build other than its optimization of the SHA routines for generating blocks is slow.

Satoshi

Satoshi

来源

阅读字号

选择适合你的字号,之后阅读会继续使用。