strange function

Discussion in 'C Programming' started by Bill Cunningham, Aug 31, 2010.

  1. 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
     
    Bill Cunningham, Aug 31, 2010
    #1
    1. Advertising

  2. "Bill Cunningham" <> writes:
    > 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).

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Aug 31, 2010
    #2
    1. Advertising

  3. Vincenzo Mercuri wrote:

    > 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
     
    Bill Cunningham, Aug 31, 2010
    #3
  4. 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
     
    Bill Cunningham, Aug 31, 2010
    #4
  5. Keith Thompson <> writes:

    > "Bill Cunningham" <> writes:
    >> 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).


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

    --
    Ben.
     
    Ben Bacarisse, Sep 1, 2010
    #5
  6. Ben Bacarisse wrote:

    > 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
     
    Bill Cunningham, Sep 1, 2010
    #6
  7. "Bill Cunningham" <> writes:
    > Ben Bacarisse wrote:
    >> 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?


    This is explained in the man pages for both functions.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Sep 1, 2010
    #7
  8. "Bill Cunningham" <> writes:

    > Ben Bacarisse wrote:
    >
    >> 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 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.

    --
    Ben.
     
    Ben Bacarisse, Sep 1, 2010
    #8
  9. [OT]Re: strange function

    Keith Thompson wrote:

    > 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
     
    Bill Cunningham, Sep 1, 2010
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Vanns
    Replies:
    7
    Views:
    7,120
    Evan Carew
    Jan 21, 2004
  2. komal
    Replies:
    6
    Views:
    1,454
    msalters
    Jan 25, 2005
  3. Harvey Twyman
    Replies:
    8
    Views:
    582
    August Derleth
    Oct 25, 2003
  4. Replies:
    2
    Views:
    955
    Bengt Richter
    Aug 1, 2005
  5. AlexHWGUY
    Replies:
    5
    Views:
    173
    John W. Krahn
    Oct 24, 2006
Loading...

Share This Page