This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
fstream::eof() doesn't work on AIX
- From: xiaoyi wang <xyaswang at yahoo dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Tue, 1 May 2007 10:29:18 -0700 (PDT)
- Subject: fstream::eof() doesn't work on AIX
Hi,
I'm working with gcc 4.1.0 on AIX 5.2(RS6000) and
encountered a problem in fstream::eof(). When
<pthread.h> is included ahead of STL header file
<fstream>, fstream::eof() won't return the correct
value when reaching to the end of the stream. If I
include <pthread.h> after including <fstream>, my test
program works correctly. Any ideas on what's going
wrong? Here is the simple test case( "text.txt" in
this test case could be any plain text file):
test.cpp:
~~~~~~~~~~~~
#include <pthread.h>
#include <stdio.h>
#include <fstream>
/*#include <pthread.h> The program will work well if
pthread.h is moved here */
#define MAX_BUFFER 1024
int main() {
char buf1[MAX_BUFFER] = { 0 };
std::ifstream fs1((const char*)"./text.txt");
if(!fs1.is_open()){
return -1;
}
while(!fs1.bad() && !fs1.eof()){
fs1.read(buf1, MAX_BUFFER);
}
if (fs1.eof()) printf("File 1 is ended\n");
if (fs1.bad()) printf("File 1 is bad\n");
return 0;
}
~~~~~~~~~~~~
Any help is appreciated!
Thanks,
Christina
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com