help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

not able to get fd of ofstream using stdio_filebuf


From: Devika
Subject: not able to get fd of ofstream using stdio_filebuf
Date: 28 Mar 2005 01:29:18 -0800
User-agent: G2/0.2

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]