This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
pthreads, printf and cout
- From: "Alex Vinokur" <alexvn at connect dot to>
- To: cygwin at cygwin dot com
- Date: Fri, 2 Jan 2004 19:57:37 +0200
- Subject: pthreads, printf and cout
Hi,
Behavior of printf and cout in a program below is different : cout prints nothing.
What is wrong?
===================================
Windows 2000 Professional
CYGWIN_NT-5.0 1.5.4(0.94/3/2)
gcc version 3.3.1 (cygming special)
===================================
====== C++ code : foo.cpp : BEGIN ======
#include <stdio.h>
#include <iostream>
#include <pthread.h>
#include <unistd.h>
using namespace std;
extern "C" void* Run(void *)
{
printf ("printf : Run Start\n");
cout << "cout : Run Start" << endl;
sleep (3);
printf ("printf : Run Finish\n");
cout << "cout : Run Finish" << endl;
}
int main ()
{
pthread_t t1;
pthread_create(&t1, NULL, Run, NULL);
int errNum = pthread_join(t1, NULL);
printf ("printf : errNum = %d\n", errNum);
cout << "cout : errNum = " << errNum << endl;
}
====== C++ code : foo.cpp : END ========
====== Compilation & Run : BEGIN ======
$ g++ foo.cpp
$ a
printf : Run Start
printf : Run Finish
printf : errNum = 0
// cout prints nothing
====== Compilation & Run : END ========
--
=====================================
Alex Vinokur
mailto:alexvn@connect.to
http://mathforum.org/library/view/10978.html
news://news.gmane.org/gmane.comp.lang.c++.perfometer
=====================================
--
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/