Fero
Fero

Reputation: 676

package bug need fix

so today I wanted to make one particular package and it always "compile errors" here, can any1 tell me what to fix in the fdwbackend.h file? I'm not a c coder but I think this shouldn't be hard one.. or?

this is log from terminal:

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

here is the fdwbackend.h code:

#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

(if you want to see the whole thing: https://github.com/HarpyWar/pvpgn)

Upvotes: 0

Views: 170

Answers (1)

laune
laune

Reputation: 31300

You cannot define a string literal as the default for a reference.

Omit the reference, use plain pass-by-value

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

Upvotes: 1

Related Questions