包错误需要修复

package bug need fix

本文关键字:错误 包错误      更新时间:2023-10-16

所以今天我想制作一个特定的包,它总是在这里"编译错误"告诉我在fdwbackend.h文件中修复什么?我不是c程序员,但我认为这应该不难。。或

这是来自终端的日志:

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

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

不能将字符串文字定义为引用的默认值。

省略引用,使用纯传递值

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