Frage

In a recently created project I have this error when trying to make:

Note: params.h:11 is just #include <string>

Building file: ../src/cmds/params.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/cmds/params.d" -MT"src/cmds/params.d" -o "src/cmds/params.o" "../src/cmds/params.cpp"
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/string:40,
                 from ../src/cmds/params.h:11,
                 from ../src/cmds/params.cpp:8:
/usr/include/c++/4.8/bits/stl_algobase.h: In instantiation of ‘static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = char*; _OI = std::ostream_iterator<std::basic_string<char> >]’:
/usr/include/c++/4.8/bits/stl_algobase.h:390:70:   required from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = std::ostream_iterator<std::basic_string<char> >]’
/usr/include/c++/4.8/bits/stl_algobase.h:428:38:   required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; _OI = std::ostream_iterator<std::basic_string<char> >]’
/usr/include/c++/4.8/bits/stl_algobase.h:460:17:   required from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; _OI = std::ostream_iterator<std::basic_string<char> >]’
../src/cmds/params.cpp:96:81:   required from here
/usr/include/c++/4.8/bits/stl_algobase.h:335:18: error: invalid user-defined conversion from ‘char’ to ‘const std::basic_string<char>&’ [-fpermissive]
        *__result = *__first;
                  ^
In file included from /usr/include/c++/4.8/string:53:0,
                 from ../src/cmds/params.h:11,
                 from ../src/cmds/params.cpp:8:
/usr/include/c++/4.8/bits/basic_string.tcc:212:5: note: candidate is: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
     basic_string<_CharT, _Traits, _Alloc>::
     ^
/usr/include/c++/4.8/bits/basic_string.tcc:212:5: note:   no known conversion for argument 1 from ‘char’ to ‘const char*’
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/string:40,
                 from ../src/cmds/params.h:11,
                 from ../src/cmds/params.cpp:8:
/usr/include/c++/4.8/bits/stl_algobase.h:335:18: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
        *__result = *__first;
                  ^
In file included from /usr/include/c++/4.8/string:53:0,
                 from ../src/cmds/params.h:11,
                 from ../src/cmds/params.cpp:8:
/usr/include/c++/4.8/bits/basic_string.tcc:212:5: error:   initializing argument 1 of ‘std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ [-fpermissive]
     basic_string<_CharT, _Traits, _Alloc>::
     ^
make: *** [src/cmds/params.o] Error 1

What could be the cause?

War es hilfreich?

Lösung

The following error is important here

    /usr/include/c++/4.8/bits/stl_algobase.h:335:18: 
error: invalid user-defined conversion from ‘char’ to ‘const std::basic_string<char>&’ [-fpermissive]
            *__result = *__first;

This indicates that somewhere in your program you are trying to convert char to std::string which is not possible.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top