包bug需要修复

时间:2014-04-20 15:15:23

标签: c++ macos makefile cmake

所以今天我想制作一个特定的包,它总是“编译错误”,可以任意1 告诉我在fdwbackend.h文件中要修复什么?我不是一个编码员,但我认为这不应该是一个难的......或者?

这是来自终端的日志:

mp41:build H$ make
[  8%] Built target compat
[  8%] Building CXX object src/common/CMakeFiles/common.dir/fdwatch.o
In file included from /Users/H/Documents/gitprojects/pvpgn/src/common/fdwatch.cpp:29:
In file included from /Users/H/Documents/gitprojects/pvpgn/src/common/fdwatch_select.h:31:
/Users/H/Documents/gitprojects/pvpgn/src/common/fdwbackend.h:36:42: error: reference to type
  'const std::string'
  (aka 'const basic_string<char, char_traits<char>, allocator<char> >') could not bind to
  an lvalue of type 'const char [1]'
                    explicit InitError(const std::string& str = "")
                                                          ^     ~~
/Users/H/Documents/gitprojects/pvpgn/src/common/fdwbackend.h:36:42: note: passing argument to
  parameter 'str' here
1 error generated.
make[2]: *** [src/common/CMakeFiles/common.dir/fdwatch.o] Error 1
make[1]: *** [src/common/CMakeFiles/common.dir/all] Error 2
make: *** [all] Error 2

这里是fdwbackend.h代码:

#ifndef __PVPGN_FDWBACKEND_INCLUDED__
#define __PVPGN_FDWBACKEND_INCLUDED__

#include <stdexcept>

namespace pvpgn
{

class FDWBackend
{
public:
    class InitError :public std::runtime_error
    {
    public:
        explicit InitError(const std::string& str = "")
            :std::runtime_error(str) {}
        ~InitError() throw() {}
    };

    explicit FDWBackend(int nfds_);
    virtual ~FDWBackend() throw();

    virtual int add(int idx, unsigned rw) = 0;
    virtual int del(int idx) = 0;
    virtual int watch(long timeout_msecs) = 0;
    virtual void handle() = 0;

protected:
    int nfds;
};

}

#endif /* __PVPGN_FDWBACKEND_INCLUDED__ */

thanx for reply

(如果你想看到整件事:https://github.com/HarpyWar/pvpgn

1 个答案:

答案 0 :(得分:1)

您无法将字符串文字定义为参考的默认值。

省略引用,使用普通的pass-by-value

explicit InitError(const std::string str = "")
        :std::runtime_error(str) {}