stdio.h ?

Discussion in 'C Programming' started by \(ProteanThread\), Mar 8, 2005.

  1. can "stdio.h" be OS specific at the kernal level or ? i know what I'm
    trying to ask here but not sure how to word it :)


    --
    Woodzy
    http://www.rtdos.com/forum
     
    \(ProteanThread\), Mar 8, 2005
    #1
    1. Advertising

  2. \(ProteanThread\)

    Minti Guest

    Sorry, could you try to reword your post. I am quite sure many would
    like to answer your question.
     
    Minti, Mar 8, 2005
    #2
    1. Advertising

  3. [posting from comp.lang.c; fups set]

    On Tue, 8 Mar 2005, (ProteanThread) wrote:
    >
    > can "stdio.h" be OS specific at the kernal level or ? i know what I'm
    > trying to ask here but not sure how to word it :)


    You mean, what's "inside" <stdio.h>? The answer, as far as this
    newsgroup is concerned (i.e., as far as the standard C language is
    concerned) is: Whatever the implementor feels like. Could be completely
    high-level stuff; could be lines and lines of machine-specific assembly
    code; could be a bunch of Unix system calls; could be pink elephants
    in tutus. We don't know what <stdio.h> "looks" like on your system, and
    we don't care. You don't need to care, either, if all you're doing is
    writing programs in C.

    If your implementation is like many other implementations, you'll
    actually have a text file somewhere on your hard disk called "stdio.h".
    If you can find it, open it up and take a look. You'll probably find
    out that it's full of arcane, basically incomprehensible pseudo-C with
    lots of underscores in funny places. Don't ask us what it means; we
    don't know. (Or rather, some of us probably do know what it all means
    on /our/ systems, but may have no idea about yours --- and besides, if
    we start explaining implementation internals to you, then we'll have to
    explain implementation internals to everyone, and there are /hundreds/
    of of implementations out there, all different. And then there wouldn't
    be any room here to talk about C anymore.)

    Bottom line: The implementation of <stdio.h> contains tygers. This
    newsgroup doesn't talk about tygers. But if you have questions about
    how to use <stdio.h> or the standard library functions it defines,
    this is definitely the place to ask.

    HTH,
    -Arthur
     
    Arthur J. O'Dwyer, Mar 8, 2005
    #3
  4. \(ProteanThread\)

    -berlin.de Guest

    In comp.lang.c "\(ProteanThread\)" <> wrote:
    > can "stdio.h" be OS specific at the kernal level or ? i know what I'm
    > trying to ask here but not sure how to word it :)


    What means "OS specific at the kernal level"? If you have a kernel
    header named "stdio.h" it got nothing to do with the file of the
    same name used for userland programs. And the userland header also
    depends on OS specific properties, the compiler and the libc, so it
    won't be identical to a "stdio.h" you get for a different system/
    compiler/libc combination.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ -berlin.de
    \__________________________ http://www.toerring.de
     
    -berlin.de, Mar 8, 2005
    #4
  5. <-berlin.de> wrote in message
    news:...
    >
    > What means "OS specific at the kernal level"? If you have a kernel
    > header named "stdio.h" it got nothing to do with the file of the
    > same name used for userland programs. And the userland header also
    > depends on OS specific properties, the compiler and the libc, so it
    > won't be identical to a "stdio.h" you get for a different system/
    > compiler/libc combination.


    so "stdio.h" is not the same not only from compiler to compiler but also
    from OS to OS ?
     
    \(ProteanThread\), Mar 8, 2005
    #5
  6. "Minti" <> wrote in message
    news:...
    > Sorry, could you try to reword your post. I am quite sure many would
    > like to answer your question.
    >


    sorry, what I mean is "stdio.h" compiler dependent or OS dependent? or can
    I create my own "stdio.h" lib for my own OS ?
     
    \(ProteanThread\), Mar 8, 2005
    #6
  7. "Arthur J. O'Dwyer" <> wrote in message
    news:p...
    >
    > You mean, what's "inside" <stdio.h>? The answer, as far as this
    > newsgroup is concerned (i.e., as far as the standard C language is
    > concerned) is: Whatever the implementor feels like. Could be completely
    > high-level stuff; could be lines and lines of machine-specific assembly
    > code; could be a bunch of Unix system calls; could be pink elephants
    > in tutus. We don't know what <stdio.h> "looks" like on your system, and
    > we don't care. You don't need to care, either, if all you're doing is
    > writing programs in C.


    So its more compiler dependent than OS dependent?

    > If your implementation is like many other implementations, you'll
    > actually have a text file somewhere on your hard disk called "stdio.h".
    > If you can find it, open it up and take a look. You'll probably find
    > out that it's full of arcane, basically incomprehensible pseudo-C with
    > lots of underscores in funny places. Don't ask us what it means; we
    > don't know. (Or rather, some of us probably do know what it all means
    > on /our/ systems, but may have no idea about yours --- and besides, if
    > we start explaining implementation internals to you, then we'll have to
    > explain implementation internals to everyone, and there are /hundreds/
    > of of implementations out there, all different. And then there wouldn't
    > be any room here to talk about C anymore.)


    But if i were designing my own OS, can I create my own custom "stdio.h" lib
    ?

    > Bottom line: The implementation of <stdio.h> contains tygers. This
    > newsgroup doesn't talk about tygers. But if you have questions about
    > how to use <stdio.h> or the standard library functions it defines,
    > this is definitely the place to ask.


    ok, few more questions:
    1. what's a tyger?
    2. can the standard library be redefined? (i.e. create my own standard
    library?)
    3. is "stdio.h" always necessary in plain C?

    I'm probably going to be sticking my foot in my mouth with the next
    question, but -
    Can I create my own subset of the C language with custom library functions?
     
    \(ProteanThread\), Mar 8, 2005
    #7
  8. (ProteanThread) wrote:
    > "Arthur J. O'Dwyer" <> wrote in message
    > news:p...
    >
    >> You mean, what's "inside" <stdio.h>? The answer, as far as this
    >>newsgroup is concerned (i.e., as far as the standard C language is
    >>concerned) is: Whatever the implementor feels like. Could be completely
    >>high-level stuff; could be lines and lines of machine-specific assembly
    >>code; could be a bunch of Unix system calls; could be pink elephants
    >>in tutus. We don't know what <stdio.h> "looks" like on your system, and
    >>we don't care. You don't need to care, either, if all you're doing is
    >>writing programs in C.

    >
    > So its more compiler dependent than OS dependent?


    Both. You have to differentiate between the
    interface (standard) and the implementation (by
    essence not standard). The interface is specified
    by the C standard and the implementation is
    specified by the compiler.

    There are many scenarios but here`s one: the OS
    implements low-level functions. You have a C
    compiler targeted for your system and it comes
    with a standard library. What 'targeted' means is
    that its C library makes system calls to your
    kernel's low-level functions. Porting that
    library to another platform will probably not
    work, because it is inherently platform-specific,
    as the compiler is.

    >> If your implementation is like many other implementations, you'll
    >>actually have a text file somewhere on your hard disk called "stdio.h".
    >>If you can find it, open it up and take a look. You'll probably find
    >>out that it's full of arcane, basically incomprehensible pseudo-C with
    >>lots of underscores in funny places. Don't ask us what it means; we
    >>don't know. (Or rather, some of us probably do know what it all means
    >>on /our/ systems, but may have no idea about yours --- and besides, if
    >>we start explaining implementation internals to you, then we'll have to
    >>explain implementation internals to everyone, and there are /hundreds/
    >>of of implementations out there, all different. And then there wouldn't
    >>be any room here to talk about C anymore.)

    >
    >
    > But if i were designing my own OS, can I create my own custom "stdio.h" lib
    > ?


    The header should be about the same in all
    libraries, because it specifies the interface.

    >> Bottom line: The implementation of <stdio.h> contains tygers. This
    >>newsgroup doesn't talk about tygers. But if you have questions about
    >>how to use <stdio.h> or the standard library functions it defines,
    >>this is definitely the place to ask.

    >
    >
    > ok, few more questions:
    > 1. what's a tyger?


    Dunno.

    > 2. can the standard library be redefined? (i.e. create my own standard
    > library?)


    The standard library *must* be implemented for
    your platform! It is mandatory for you to
    re-implement a working library or to start one
    from scratch.

    > 3. is "stdio.h" always necessary in plain C?


    What do you mean exactly? It is necessary if the
    program uses declarations from that header.

    > I'm probably going to be sticking my foot in my mouth with the next
    > question, but -
    > Can I create my own subset of the C language with custom library functions?


    Yes. For example, Visual C++ adds many extensions
    to the C++ language. Just make sure you specify
    somewhere what is standard and what is not (and
    make sure your standard library's implementation
    does not use non-standard feature, as Visual C++
    does).

    By the way, you should remove comp.lang.c from the
    crosspost list since your questions have nothing
    to do with it (read its charter).


    Jonathan
     
    Jonathan Mcdougall, Mar 8, 2005
    #8
  9. In article <1110314052.a0171dc3b7d8af51905c6a79ed1062c0@teranews>,
    \(ProteanThread\) <> wrote:
    :sorry, what I mean is "stdio.h" compiler dependent or OS dependent?

    Both. In fact, it need not even be text, according to the C89 standard.

    :eek:r can
    :I create my own "stdio.h" lib for my own OS ?

    You could, but don't expect the result to be portable.

    Within the last couple of weeks, there was a thread here in comp.lang.c
    to the effect that users are "prohibitted from trying" to redefine
    any routine in the standard library. I was the lone holdout for
    the interpretation that the standard didn't actually prohibit you
    from trying: it just couldn't promise that anything would work
    properly if you did.
    --
    I was very young in those days, but I was also rather dim.
    -- Christopher Priest
     
    Walter Roberson, Mar 8, 2005
    #9
  10. In article <XnoXd.83158$>,
    Jonathan Mcdougall <> wrote:
    :By the way, you should remove comp.lang.c from the
    :crosspost list since your questions have nothing
    :to do with it (read its charter).

    And where exactly can that charter be found?

    comp.lang.c is a rename of a news.* group. It effectively
    predates charters. The corresponding news.* group did have a statement
    of purpose, but you will, sad to say, get royally roasted if you
    post according to that news.* statement of purpose. :(
    --
    Oh, to be a Blobel!
     
    Walter Roberson, Mar 8, 2005
    #10
  11. In article <1110313975.c43093294dde52595a6a7a3c877c3a48@teranews>,
    \(ProteanThread\) <> wrote:
    :so "stdio.h" is not the same not only from compiler to compiler but also
    :from OS to OS ?

    Different from OS to OS for certain.

    On unix-type systems that are supplied with <stdio.h> and so on
    as part of the OS, most compiler writers try to work within what
    is provided. Unix(tm) OS's have to have ANSI-compliant header
    files in order to pass the Unix(tm) conformance tests.

    Once you get into Windows and so on, you are dealing more with
    competing compilers which might use completely different header files.
    --
    Warning: potentially contains traces of nuts.
     
    Walter Roberson, Mar 8, 2005
    #11
  12. In article <1110314389.d4527d3074cde45f4ace6396d62a5df4@teranews>,
    \(ProteanThread\) <> wrote:
    :eek:k, few more questions:
    :1. what's a tyger?

    The old spelling of 'tiger'. On old maps, in places unknown and
    potentially dangerous, it was supposedly common to put on the map,
    "Beyond here be tygers."

    :3. is "stdio.h" always necessary in plain C?

    No! The C89 standard says in a footnote,
    89. A header is not nessisarily a source file [...]
    --
    Are we *there* yet??
     
    Walter Roberson, Mar 8, 2005
    #12
  13. "Walter Roberson" <-cnrc.gc.ca> wrote in message
    news:d0l4f4$et$...
    >
    > And where exactly can that charter be found?
    >
    > comp.lang.c is a rename of a news.* group. It effectively
    > predates charters. The corresponding news.* group did have a statement
    > of purpose, but you will, sad to say, get royally roasted if you
    > post according to that news.* statement of purpose. :(



    I wonder if he means "comp.lang.c.moderated" ?
     
    \(ProteanThread\), Mar 8, 2005
    #13
  14. "Walter Roberson" <-cnrc.gc.ca> wrote in message
    news:d0l48h$7$...
    >
    > You could, but don't expect the result to be portable.
    >


    So in order to keep it portable I'd want to keep my own definitions separate
    from the standard library ?

    > Within the last couple of weeks, there was a thread here in comp.lang.c
    > to the effect that users are "prohibitted from trying" to redefine
    > any routine in the standard library. I was the lone holdout for
    > the interpretation that the standard didn't actually prohibit you
    > from trying: it just couldn't promise that anything would work
    > properly if you did.


    Well, aren't there a few well used languages that are either a subset of C
    or a variation of C ?
     
    \(ProteanThread\), Mar 8, 2005
    #14
  15. "Jonathan Mcdougall" <> wrote in message
    news:XnoXd.83158$...
    >
    > Both. You have to differentiate between the
    > interface (standard) and the implementation (by
    > essence not standard). The interface is specified
    > by the C standard and the implementation is
    > specified by the compiler.
    >


    ok that makes sense.

    > There are many scenarios but here`s one: the OS
    > implements low-level functions. You have a C
    > compiler targeted for your system and it comes
    > with a standard library. What 'targeted' means is
    > that its C library makes system calls to your
    > kernel's low-level functions. Porting that
    > library to another platform will probably not
    > work, because it is inherently platform-specific,
    > as the compiler is.


    so really, i'd want to keep the standard C library definitions intact and
    just add my own OS specific functions?

    > The header should be about the same in all
    > libraries, because it specifies the interface.


    But would I want to make "stdio.h" more specific to my OS / Compiler ?

    > The standard library *must* be implemented for
    > your platform! It is mandatory for you to
    > re-implement a working library or to start one
    > from scratch.


    Any examples?

    > What do you mean exactly? It is necessary if the
    > program uses declarations from that header.


    But can the header be defined to use only functions that pertain to my OS ?

    > Yes. For example, Visual C++ adds many extensions
    > to the C++ language. Just make sure you specify
    > somewhere what is standard and what is not (and
    > make sure your standard library's implementation
    > does not use non-standard feature, as Visual C++
    > does).


    Makes sense (but microsoft usually never follows the rules anyways)

    > By the way, you should remove comp.lang.c from the
    > crosspost list since your questions have nothing
    > to do with it (read its charter).


    I plan on only using C (or a subset of C) and Assembler for my OS :)
     
    \(ProteanThread\), Mar 8, 2005
    #15
  16. "Walter Roberson" <-cnrc.gc.ca> wrote in message
    news:d0l56p$16k$...
    >
    > The old spelling of 'tiger'. On old maps, in places unknown and
    > potentially dangerous, it was supposedly common to put on the map,
    > "Beyond here be tygers."
    >


    lol. now i understand the relevance. :)

    > :3. is "stdio.h" always necessary in plain C?
    >
    > No! The C89 standard says in a footnote,
    > 89. A header is not nessisarily a source file [...]


    is C89 the last C standard or most recent definition ?

    > --
    > Are we *there* yet??


    I wish. :)
     
    \(ProteanThread\), Mar 8, 2005
    #16
  17. \(ProteanThread\)

    CBFalconer Guest

    Jonathan Mcdougall wrote:
    > (ProteanThread) wrote:
    >

    .... snip ...
    >>
    >> ok, few more questions:
    >> 1. what's a tyger?

    >
    > Dunno.


    It is closely related to a tigger (spelled with a double guh) and
    specifies a striped yet powerful mythical beast that is sometimes
    friendly. Cartologists have been known to specify areas where
    "Here there be tygers". Cartoonists and illustrators tend to lean
    towards tiggers. The C standard stands aloof in the matter and
    allows you to redefine both flavors.

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Mar 8, 2005
    #17
  18. Tygers

    (ProteanThread) wrote:

    > 1. what's a tyger?


    Tyger! Tyger! burning bright
    In the forests of the night,
    What immortal hand or eye
    Could frame thy fearful symmetry?

    In what distant deeps or skies
    Burnt the fire of thine eyes?
    On what wings dare he aspire?
    What the hand, dare seize the fire?

    And what shoulder, & what art,
    Could twist the sinews of thy heart?
    And when thy heart began to beat,
    What dread hand? & what dread feet?

    What the hammer? what the chain?
    In what furnace was thy brain?
    What the anvil? what dread grasp
    Dare its deadly terrors clasp?

    When the stars threw down their spears,
    And water'd heaven with their tears,
    Did he smile his work to see?
    Did he who made the Lamb make thee?

    Tyger! Tyger! burning bright
    In the forests of the night,
    What immortal hand or eye
    Dare frame thy fearful symmetry?

    -- William Blake
     
    E. Robert Tisdale, Mar 8, 2005
    #18
  19. In article <1110320853.164b2acfba50312e865d1735f8b3c98a@teranews>,
    \(ProteanThread\) <> wrote:
    :So in order to keep it portable I'd want to keep my own definitions separate
    :from the standard library ?

    Right. But I'm not sure how you intend to impliment a portable
    operating system? I/O is always going to be platform dependant.

    :Well, aren't there a few well used languages that are either a subset of C
    :eek:r a variation of C ?

    Subset? I can't think of any.
    Variation? Some people would consider C++, C#, and Java to be
    "variations" on C.

    If you are trying to find a language that says, "It's okay to
    redefine the system library routines," then the only one I can think
    of at the moment is Forth. LISP and Scheme too maybe.
    --
    "No one has the right to destroy another person's belief by
    demanding empirical evidence." -- Ann Landers
     
    Walter Roberson, Mar 8, 2005
    #19
  20. In article <1110321509.874f748acd8c835cd795a4a9d0a5dfd1@teranews>,
    \(ProteanThread\) <> wrote:

    :is C89 the last C standard or most recent definition ?

    There is a 1999 international C standard. There are, though,
    not a great number of compilers built for that standard yet.
    --
    "I want to make sure [a user] can't get through ... an online
    experience without hitting a Microsoft ad"
    -- Steve Ballmer [Microsoft Chief Executive]
     
    Walter Roberson, Mar 8, 2005
    #20
    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. Robert Maas, see http://tinyurl.com/uh3t

    How to disable stdio echoplex from java code (unix specific)?

    Robert Maas, see http://tinyurl.com/uh3t, Jun 7, 2005, in forum: Java
    Replies:
    0
    Views:
    395
    Robert Maas, see http://tinyurl.com/uh3t
    Jun 7, 2005
  2. Vicent

    iostream or stdio

    Vicent, Aug 25, 2003, in forum: C++
    Replies:
    2
    Views:
    1,732
  3. paul calvert
    Replies:
    6
    Views:
    2,160
  4. fang
    Replies:
    1
    Views:
    576
    Victor Bazarov
    Apr 13, 2005
  5. Replies:
    18
    Views:
    1,906
    crazzybugger
    Oct 22, 2006
Loading...

Share This Page