delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/15/16:57:54

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Sent: 15 Oct 2002 20:57:29 GMT
Message-ID: <004501c2748d$6b2d0b00$f400a8c0@xypoint.com>
From: "Abraham Backus" <abraham AT backus DOT com>
To: "Lapo Luchini" <lapo AT lapo DOT it>, "Mailing List: CygWin" <cygwin AT cygwin DOT com>
References: <3DAC5A61 DOT 3010701 AT lapo DOT it>
Subject: Re: gcc3 bug or I've got some file wrong?
Date: Tue, 15 Oct 2002 13:57:03 -0700
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

Lapo,

I don't have a reference to std iostreams handy, but having seen errors like
this many times before, I can tell you what's up.

Even though it looks like there is an error in a system/standard header, it
is actually an indication of where the compiler ended up after
parsing/preprocessing when it discovered an error.  The best way that I
figured out to decipher these types of errors is to ignore all the template
stuff (replace with "XXX") and read the errors themselves:
In copy constructor XXX: XXX is private XXX within this context
(repeated)

From this, I concluded that the template/class is using the common practice
of "hiding" the copy constructor by making it private (See Scott Meyers
"Effective C++" I believe).  This is to enforce that the class isn't meant
to be copied.  There are a few different scenarios when a copy constructor
is called.  Meyers provides a good description of this practice in "Item 27:
Explicitly disallow use of implicitly generated member functions you don't
want" and "Item 45: Know what functions C++ silently writes and calls".  I
also recommend reading "Effective STL", which has "Item 49: Learn to
decipher STL-related compiler diagnostics", with some useful information on
deciphering template errors.

I don't know what the solution in your case is without looking at your code.
You are using a subclass of std::basic_ios, most likely std::basic_ostream,
std::basic_istream or one of their fstream counterparts.  Try experimenting
with using references if you are passing around an instance like this.

For example:

void readSomething(std::istream & in)
{
// ... some stuff to read from the stream
}

int main(int argc, char ** argv)
{
    std::ifstream fin(argv[0]);

    readSomething(fin);
}

-Abe

----- Original Message -----
> That's the error.. but seems strange to me that a system header has a
> problem, anyone has an idea?
>
> $ make
> g++ -ggdb  -c -o icse.o icse.cc
> /usr/include/c++/3.2/bits/ios_base.h: In copy constructor
> `std::basic_ios<char,
>
>    std::char_traits<char> >::basic_ios(const std::basic_ios<char,
>    std::char_traits<char> >&)':
> /usr/include/c++/3.2/bits/ios_base.h:421: `std::ios_base::ios_base(const
>    std::ios_base&)' is private
> /usr/include/c++/3.2/iostream:62: within this context
> /usr/include/c++/3.2/streambuf: In copy constructor
> `std::basic_filebuf<char,
>    std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char,
>    std::char_traits<char> >&)':
> /usr/include/c++/3.2/streambuf:486: `std::basic_streambuf<_CharT,
>    _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&)
>    [with _CharT = char, _Traits = std::char_traits<char>]' is private
> /usr/include/c++/3.2/iostream:62: within this context
> make: *** [icse.o] Error 1



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019