$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Steve Byan (smb_at_[hidden])
Date: 2006-01-25 14:06:51
I'm used to declaring main() as
        int main (int argc, const char * argv[])
Attempting to use boost::program_options with a const char * argv[]  
results in the compilation errors appended below on SLES 9 with gcc  
3.3.3. Similar errors are reported on Mac OS 10.4.4 with gcc 4.0.1.
First, I'd consider it an enhancement if program_options were to  
support a const char * argv[].
Second, is program_options actually modifying argv? Note the last error:
"/usr/include/g++/bits/basic_string.tcc:160: error: assignment of  
read-only
    location"
Regards,
-Steve
/usr/bin/g++ -c  -UNDEBUG -DDEBUG -Dpowerpc -Ddarwin6_0 -I/home/smb/ 
boston/HEAD/boston/common/iscsi/src -I/home/smb/boston/HEAD/boston/ 
common/iscsi/share/include   -g -O0 -L/home/smb/boston/HEAD/boston/ 
common/iscsi/share/lib   -MD -o iscsi_dvd_targetd.o  
iscsi_dvd_targetd.cpp
iscsi_dvd_targetd.cpp: In function `int main(int, const char**)':
iscsi_dvd_targetd.cpp:31: error: no matching function for call to  
`store(
    boost::program_options::basic_parsed_options<const char>,
    boost::program_options::variables_map&)'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/variables_map.hpp:138: error: candidates
    are: void boost::program_options::store(const
    boost::program_options::basic_parsed_options<char>&,
    boost::program_options::variables_map&, bool)
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/variables_map.hpp:146: error:
                   void boost::program_options::store(const
    boost::program_options::basic_parsed_options<wchar_t>&,
    boost::program_options::variables_map&)
/usr/include/g++/bits/stl_alloc.h: At global scope:
/usr/include/g++/bits/stl_alloc.h: In instantiation of  
`std::allocator<const char>':
/usr/include/g++/bits/basic_string.h:116:   instantiated from  
`std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >'
/usr/include/g++/bits/stl_vector.h:162:   instantiated from  
`std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp =  
std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >, _Alloc =  
std::allocator<std::basic_string<const char, std::char_traits<const  
char>, std::allocator<const char> > >]'
/usr/include/g++/bits/stl_vector.h:229:   instantiated from  
`std::vector<_Tp, _Alloc>::vector(typename std::_Vector_base<_Tp,  
_Alloc>::allocator_type&) [with _Tp = std::basic_string<const char,  
std::char_traits<const char>, std::allocator<const char> >, _Alloc =  
std::allocator<std::basic_string<const char, std::char_traits<const  
char>, std::allocator<const char> > >]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:18:   instantiated from  
`std::vector<std::basic_string<_CharT, std::char_traits<_CharT>,  
std::allocator<_CharT> >, std::allocator<std::basic_string<_CharT,  
std::char_traits<_CharT>, std::allocator<_CharT> > > >  
boost::program_options::detail::make_vector(Iterator, Iterator) [with  
charT = const char, Iterator = const char**]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/usr/include/g++/bits/stl_alloc.h:662: error: `const _Tp*
    std::allocator<_Alloc>::address(const _Tp&) const [with _Tp =  
const char]'
    and `_Tp* std::allocator<_Alloc>::address(_Tp&) const [with _Tp =  
const
    char]' cannot be overloaded
/usr/include/g++/bits/basic_string.tcc: In instantiation of  
`std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >':
/usr/include/g++/bits/stl_vector.h:162:   instantiated from  
`std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp =  
std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >, _Alloc =  
std::allocator<std::basic_string<const char, std::char_traits<const  
char>, std::allocator<const char> > >]'
/usr/include/g++/bits/stl_vector.h:229:   instantiated from  
`std::vector<_Tp, _Alloc>::vector(typename std::_Vector_base<_Tp,  
_Alloc>::allocator_type&) [with _Tp = std::basic_string<const char,  
std::char_traits<const char>, std::allocator<const char> >, _Alloc =  
std::allocator<std::basic_string<const char, std::char_traits<const  
char>, std::allocator<const char> > >]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:18:   instantiated from  
`std::vector<std::basic_string<_CharT, std::char_traits<_CharT>,  
std::allocator<_CharT> >, std::allocator<std::basic_string<_CharT,  
std::char_traits<_CharT>, std::allocator<_CharT> > > >  
boost::program_options::detail::make_vector(Iterator, Iterator) [with  
charT = const char, Iterator = const char**]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/usr/include/g++/bits/basic_string.h:307: error: `static void
    std::basic_string<_CharT, _Traits, _Alloc>::_S_copy_chars(_CharT*,
    __gnu_cxx::__normal_iterator<typename _Alloc::const_pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::const_pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >) [with _CharT =  
const char,
    _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]
    ' and `static void std::basic_string<_CharT, _Traits,
    _Alloc>::_S_copy_chars(_CharT*,  
__gnu_cxx::__normal_iterator<typename
    _Alloc::pointer, std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >) [with _CharT =  
const char,
    _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]
    ' cannot be overloaded
/usr/include/g++/bits/basic_string.h:315: error: `static void
    std::basic_string<_CharT, _Traits, _Alloc>::_S_copy_chars 
(_CharT*, const
    _CharT*, const _CharT*) [with _CharT = const char, _Traits =
    std::char_traits<const char>, _Alloc = std::allocator<const  
char>]' and `
    static void std::basic_string<_CharT, _Traits,
    _Alloc>::_S_copy_chars(_CharT*, _CharT*, _CharT*) [with _CharT =  
const char,
    _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]
    ' cannot be overloaded
/usr/include/g++/bits/basic_string.h:636: error:  
`std::basic_string<_CharT,
    _Traits, _Alloc>& std::basic_string<_CharT, _Traits,
    _Alloc>::replace(__gnu_cxx::__normal_iterator<typename  
_Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >, const _CharT*,  
const _CharT*)
    [with _CharT = const char, _Traits = std::char_traits<const  
char>, _Alloc =
    std::allocator<const char>]' and `std::basic_string<_CharT, _Traits,
    _Alloc>& std::basic_string<_CharT, _Traits,
    _Alloc>::replace(__gnu_cxx::__normal_iterator<typename  
_Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >, _CharT*, _CharT*)  
[with _CharT
    = const char, _Traits = std::char_traits<const char>, _Alloc =
    std::allocator<const char>]' cannot be overloaded
/usr/include/g++/bits/basic_string.h:647: error:  
`std::basic_string<_CharT,
    _Traits, _Alloc>& std::basic_string<_CharT, _Traits,
    _Alloc>::replace(__gnu_cxx::__normal_iterator<typename  
_Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::const_pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::const_pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >) [with _CharT =  
const char,
    _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]
    ' and `std::basic_string<_CharT, _Traits, _Alloc>&  
std::basic_string<_CharT,
    _Traits, _Alloc>::replace(__gnu_cxx::__normal_iterator<typename
    _Alloc::pointer, std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >,
    __gnu_cxx::__normal_iterator<typename _Alloc::pointer,
    std::basic_string<_CharT, _Traits, _Alloc> >) [with _CharT =  
const char,
    _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]
    ' cannot be overloaded
/usr/include/g++/bits/basic_string.h: In member function `
    std::basic_string<_CharT, _Traits, _Alloc>::_Rep*  
std::basic_string<_CharT,
    _Traits, _Alloc>::_M_rep() const [with _CharT = const char,  
_Traits =
    std::char_traits<const char>, _Alloc = std::allocator<const char>]':
/usr/include/g++/bits/basic_string.h:355:   instantiated from  
`std::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with  
_CharT = const char, _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:22:   instantiated from  
`std::vector<std::basic_string<_CharT, std::char_traits<_CharT>,  
std::allocator<_CharT> >, std::allocator<std::basic_string<_CharT,  
std::char_traits<_CharT>, std::allocator<_CharT> > > >  
boost::program_options::detail::make_vector(Iterator, Iterator) [with  
charT = const char, Iterator = const char**]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/usr/include/g++/bits/basic_string.h:257: error: reinterpret_cast  
from `const
    char*' to `std::basic_string<const char, std::char_traits<const  
char>,
    std::allocator<const char> >::_Rep*' casts away const (or volatile)
/usr/include/g++/bits/basic_string.tcc: In member function `_CharT*
    std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_clone(const  
_Alloc&,
    typename _Alloc::size_type) [with _CharT = const char, _Traits =
    std::char_traits<const char>, _Alloc = std::allocator<const char>]':
/usr/include/g++/bits/basic_string.h:195:   instantiated from  
`_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_Rep::_M_grab 
(const _Alloc&, const _Alloc&) [with _CharT = const char, _Traits =  
std::char_traits<const char>, _Alloc = std::allocator<const char>]'
/usr/include/g++/bits/basic_string.tcc:195:   instantiated from  
`std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const  
std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = const  
char, _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]'
/usr/include/g++/bits/stl_construct.h:78:   instantiated from `void  
std::_Construct(_T1*, const _T2&) [with _T1 = std::basic_string<const  
char, std::char_traits<const char>, std::allocator<const char> >, _T2  
= std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >]'
/usr/include/g++/bits/stl_vector.h:599:   instantiated from `void  
std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp =  
std::basic_string<const char, std::char_traits<const char>,  
std::allocator<const char> >, _Alloc =  
std::allocator<std::basic_string<const char, std::char_traits<const  
char>, std::allocator<const char> > >]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:22:   instantiated from  
`std::vector<std::basic_string<_CharT, std::char_traits<_CharT>,  
std::allocator<_CharT> >, std::allocator<std::basic_string<_CharT,  
std::char_traits<_CharT>, std::allocator<_CharT> > > >  
boost::program_options::detail::make_vector(Iterator, Iterator) [with  
charT = const char, Iterator = const char**]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/usr/include/g++/bits/basic_string.tcc:596: error: assignment of read- 
only
    location
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/convert.hpp: In
    function `std::vector<std::string, std::allocator<std::string> >
    boost::program_options::to_internal(const std::vector<T,
    std::allocator<_CharT> >&) [with T = std::basic_string<const char,
    std::char_traits<const char>, std::allocator<const char> >]':
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/convert.hpp:79: error: no
    matching function for call to `to_internal(const  
std::basic_string<const
    char, std::char_traits<const char>, std::allocator<const char> >&)'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/convert.hpp:70: error: candidates
    are: std::string boost::program_options::to_internal(const  
std::string&)
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/convert.hpp:72: error:
                   std::string boost::program_options::to_internal(const
    std::wstring&)
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp: In
    member function `boost::program_options::basic_parsed_options<charT>
    boost::program_options::basic_command_line_parser<charT>::run()  
[with charT
    = const char]':
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:106: error: no
    matching function for call to `
    boost::program_options::basic_parsed_options<const char>::
    basic_parsed_options 
(boost::program_options::basic_parsed_options<char>&)'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118: error: candidates
    are: boost::program_options::basic_parsed_options<const
    char>::basic_parsed_options(const
    boost::program_options::basic_parsed_options<const char>&)
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/parsers.hpp:35: error:
     
boost::program_options::basic_parsed_options<charT>::basic_parsed_option 
s(const
    boost::program_options::options_description*) [with charT = const  
char]
/usr/include/g++/bits/basic_string.tcc: In static member function  
`static
    _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct 
(_InIter,
    _InIter, const _Alloc&, std::forward_iterator_tag) [with _FwdIter  
= const
    char*, _CharT = const char, _Traits = std::char_traits<const  
char>, _Alloc =
    std::allocator<const char>]':
/usr/include/g++/bits/basic_string.h:670:   instantiated from `static  
_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct_aux 
(_InIter, _InIter, const _Alloc&, __false_type) [with _InIter = const  
char*, _CharT = const char, _Traits = std::char_traits<const char>,  
_Alloc = std::allocator<const char>]'
/usr/include/g++/bits/basic_string.h:687:   instantiated from `static  
_CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct 
(_InIter, _InIter, const _Alloc&) [with _InIter = const char*, _CharT  
= const char, _Traits = std::char_traits<const char>, _Alloc =  
std::allocator<const char>]'
/usr/include/g++/bits/basic_string.tcc:229:   instantiated from  
`std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const  
_CharT*, const _Alloc&) [with _CharT = const char, _Traits =  
std::char_traits<const char>, _Alloc = std::allocator<const char>]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:22:   instantiated from  
`std::vector<std::basic_string<_CharT, std::char_traits<_CharT>,  
std::allocator<_CharT> >, std::allocator<std::basic_string<_CharT,  
std::char_traits<_CharT>, std::allocator<_CharT> > > >  
boost::program_options::detail::make_vector(Iterator, Iterator) [with  
charT = const char, Iterator = const char**]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:42:   instantiated from  
`boost::program_options::basic_command_line_parser<charT>::basic_command 
_line_parser(int, charT**) [with charT = const char]'
/home/smb/boston/HEAD/boston/common/iscsi/share/include/boost/ 
program_options/detail/parsers.hpp:118:   instantiated from  
`boost::program_options::basic_parsed_options<charT>  
boost::program_options::parse_command_line(int, charT**, const  
boost::program_options::options_description&, int,  
boost::function1<std::pair<std::string, std::string>, const  
std::string&, std::allocator<boost::function_base> >) [with charT =  
const char]'
iscsi_dvd_targetd.cpp:31:   instantiated from here
/usr/include/g++/bits/basic_string.tcc:160: error: assignment of read- 
only
    location
make: *** [iscsi_dvd_targetd.o] Error 1
--------
Steve Byan <smb_at_[hidden]>
Software Architect
Egenera, Inc.
165 Forest Street
Marlboro, MA 01752
(508) 858-3125