Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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" Subject: Saving rdbuf() Date: Fri, 22 Aug 2003 16:59:01 +0300 Lines: 58 Message-ID: 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 #include 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/