not able to get fd of ofstream using stdio_filebuf
Hi,
I want to call fcntl function for which I need fd().
The code part is smthing like :
ofstream osf("somefile" , ios::app);
filebuf * fb ;
fb = osf.rdbuf();
fcntl(fb -> fd(), F_SETLKW, &cfLock);
Now this code was working fine with gcc 2.96 but now it[gcc 3.2.3] says no matching function for fd() since the function fd() of basic_filebuf has been removed in gcc 3.2.3. and they have provided new extension stdio_filebuf.
I tried following thing:
#include <ext/stdio_filebuf.h>
typedef __gnu_cxx::stdio_filebuf FILEBUF;
ofstream osf("somefile" , ios::app);
FILEBUF *fb ;
fb = dynamic_cast<FILEBUF *>(osf.rdbuf());
...But its not getting typecasted properly and i m getting segment fault.
Please help
Devika
Last edited by Devika; 03-28-2005 at 03:20 AM.
|