delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/08/22/10:01:08

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-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
From: "Alex Vinokur" <alexvn AT connect DOT to>
Subject: Saving rdbuf()
Date: Fri, 22 Aug 2003 16:59:01 +0300
Lines: 58
Message-ID: <bi57m8$d5h$1@sea.gmane.org>
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

===========================================
Windows 2000
CYGWIN_NT-5.0 1.3.22(0.78/3/2)
GNU gcc version 3.2 20020927 (prerelease)
===========================================


====== C++ code : File t.cpp : BEGIN ======

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
streambuf* save_sbuf_cout;

// ---------------------------------------
// There is a design error in this program
// ------ Should be something like : -----
// ofstream log_file ("test.out");
//  save_sbuf_cout = cout.rdbuf();
//  cout.rdbuf(log_file.rdbuf());
// ---------------------------------------

  cout << "Hello-1" << endl;
  cout.rdbuf(save_sbuf_cout);
  cout << "Hello-2" << endl;

  return 0;
}

====== C++ code : File t.cpp : END ========


====== Compilation & Run : BEGIN ======

$ g++ t.cpp

$ a
Hello-1

====== Compilation & Run : END ========

No run error is generated.

Whereas MinGW (g++ 3.2) and DJGPP (g++ 3.2) do generate run error.

Why does 'CYGWIN behavior differ from MinGW and DJGPP in this case?

   =====================================
   Alex Vinokur
     mailto:alexvn AT connect DOT to
     http://mathforum.org/library/view/10978.html
   =====================================





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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