strange function

K

Keith Thompson

Bill Cunningham said:
I thought I didn't recognize this function. The site says it's
non-standard. Is it even in ANSI C ? Does anyone know where it came from? I
think I'll stick with fflsuh().

http://www.cppreference.com/wiki/c/io/fpurge

For the benefit of others who might be curious:

fpurge was introduced in 4.4BSD. It's not in ANSI or ISO C (if it
were, it wouldn't be non-standard, would it?). The cited web page
is about C++, not C. And of course we all know that fflush()'s
behavior on input streams is undefined (fpurge() apparently does
on input streams what many people seem to think fflush() should do).
 
B

Bill Cunningham

Vincenzo said:
Try with "man 3 fpurge" on Linux. Among the other things it says:

"[...] The function fpurge() was introduced in 4.4BSD and is not
available under Linux. The function __fpurge() was introduced
in Solaris, and is present in glibc 2.1.95 and later."

Oh I see. A unix function.

Bill
 
B

Bill Cunningham

Keith Thompson wrote:

[snip]

The cited web page
is about C++, not C.

[snip]

I thought it covered both myself. I've got some pretty good results with it.
And just looking at the C part.

Bill
 
B

Ben Bacarisse

Keith Thompson said:
For the benefit of others who might be curious:

fpurge was introduced in 4.4BSD. It's not in ANSI or ISO C (if it
were, it wouldn't be non-standard, would it?). The cited web page
is about C++, not C. And of course we all know that fflush()'s
behavior on input streams is undefined (fpurge() apparently does
on input streams what many people seem to think fflush() should do).

Also, for what it's worth, what it does to output streams is quite
different to what fflush does to them.
 
B

Bill Cunningham

Ben said:
Also, for what it's worth, what it does to output streams is quite
different to what fflush does to them.

What exactly do you mean Ben? I am curious now. I have linux so my
system I doesn't have this function. Nor do I have STREAMS but luckily unix
sockets can be created for IPC between kernel and user and vice versa. What
exactly does fflush do and what does it not do that fpurge does?

Bill
 
K

Keith Thompson

Bill Cunningham said:
What exactly do you mean Ben? I am curious now. I have linux so my
system I doesn't have this function. Nor do I have STREAMS but luckily unix
sockets can be created for IPC between kernel and user and vice versa. What
exactly does fflush do and what does it not do that fpurge does?

This is explained in the man pages for both functions.
 
B

Ben Bacarisse

Bill Cunningham said:
What exactly do you mean Ben?

I don't know how to say it any clearer. fflush and fpurge are different
and they do different things. I hope you will forgive me if I don't try
to explain what each one does. Manual pages on both of them are easy to
find. I have a good memory, but I could not do any programming without
constant reference to man pages. If you don't have them, you absolutely
need to get them because you say your memory is not good.
I am curious now. I have linux so my
system I doesn't have this function.

My linux system does and it has a man page for fpurge as well as one for
fflush.
Nor do I have STREAMS but luckily unix
sockets can be created for IPC between kernel and user and vice versa.

Fortunately this seems to be off-topic because I have no idea what it
means. If it matters to you there is always comp.unix.programmer.
What
exactly does fflush do and what does it not do that fpurge does?

The both do exactly what the manual pages say they do. I don't usually
reply by saying "read the manual" but in this case I doubt I could
explain it any better than the manual does.
 
B

Bill Cunningham

Keith said:
This is explained in the man pages for both functions.

I guess I do have fpurge in my linux system though this is OT I have a
header called stdio_ext.h and __fpurge is there. Since I'm not quite keen on
using non-ANSI functions I am going to leave it alone. The only thing non
standard C I do is a little bit of socket work and knowing me I am not great
at that.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top