This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: __get_c_string


On Jun 16,  6:37pm, Benjamin Kosnik wrote:
> Subject: Re: __get_c_string
> Edwards, Phil wrote:
>
> > If one includes <string> and compiles with -Wall, this warning appears:
> >
> > .../include/g++-v3/bits/basic_string.h:974: warning: `const char *
> > __get_c_string(const string &)' defined but not used
>
> This is used for the <stdexcept> exception classes, so that they can get
> around a recursive string/exception include, and just forward declare the
> string class. It is actually used, so applying the unused attribute is
> probably not the best solution.
>
> -benjamin
>-- End of excerpt from Benjamin Kosnik

It's not really needed, though; it was a disgusting hack.  I put it in
because I wanted to keep basic things like <string> and <vector> in the
header files only, rather than giving them pieces that had to live in
libC.so.  The point is that the standard exceptions' constructors have
to manipulate strings, and circular dependencies are a problem if we
want to define those constructors in the headers themselves.

Unless you want to implement everything in <stdexcept> in the header
itself (and I really don't see why you would, unless you have the same
sort of compatiblity concerns that I did; surely the efficiency of
creating a runtime_error object doesn't matter), you don't need to do
this.  Just forward-declare basic_string in stdexcept, and then declare
_Named_exception::_Named_exception(const string&) out of line in some
.cc file.

			--Matt

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]