Re: C library and C implement

Discussion in 'C Programming' started by Malcolm McLean, Jan 1, 2014.

  1. On Wednesday, January 1, 2014 2:31:47 PM UTC, gyl wrote:
    > I am not cleared with the concept of "language library" and "language
    > implement".
    >
    > Here are my questions:
    > 1. what is a C library used for?
    > 2. Is it true that a C implement contains a C library?
    > 3. What is POSIX? is it a library standard?
    > 4. What is the difference between glibc and MSVC's c runtime library?
    > 5. How can I do some real programming with a C library?
    >
    > sorry if these questions are idiotic.
    >

    C consists of "bit shuffling" language that contains loops, arithmetic and
    logical operators, if statements, and not much more. Also function (subroutine)
    calls.
    The idea of structured programming is that subroutines are often general and
    resuable. For instance very many programs need to calculate a sine. It makes
    sense to write once then call.
    C also has a quirk that it allows functions to be compiled, then linked.
    A file containing functions for linking is called a "library". It's faster to
    link than to compile, which was the original motive. Also, functions written
    in languages other than C can often be linked, if they have compatible call
    conventions.
    C can do most things because it can write to an absolute address. So printf(),
    contrary to what people say, can often be written in pure C. I've done it myself
    on machines which had character-addressed raster screens. Sometimes however
    you do need instructions which aren't memory writes, e.g. if you have a machine
    with a flating point unit that has a hardware square root, it makes sense to
    implement the sqrt() function with this instruction.
    Malcolm McLean, Jan 1, 2014
    #1
    1. Advertising

  2. Malcolm McLean <> writes:
    [...]
    > C can do most things because it can write to an absolute address. So printf(),
    > contrary to what people say, can often be written in pure C. I've done it myself
    > on machines which had character-addressed raster screens.

    [...]

    I don't recall anyone saying that printf() can't be written in
    pure C. But it can't be written *portably* in pure C. Your
    implementation that writes to fixed memory addresses, though it
    may be perfectly appropriate for the system for which you wrote it,
    would not work on other systems. (Which is why printf() is in the
    standard library.)

    Of course printf() can be written portably given an implementation
    of putchar(); the point is that I/O can't be done without some
    system-specific support.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Working, but not speaking, for JetHead Development, Inc.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jan 1, 2014
    #2
    1. Advertising

  3. In article <>,
    Keith Thompson <> wrote:
    ....
    >I don't recall anyone saying that printf() can't be written in
    >pure C. But it can't be written *portably* in pure C. Your


    Point of order: In the religion of CLC,

    "pure C" == "portable C" == "standard C" == "C".

    --
    A Catholic woman tells her husband to buy Viagra.

    A Jewish woman tells her husband to buy Pfizer.
    Kenny McCormack, Jan 1, 2014
    #3
  4. On Thursday, January 2, 2014 10:40:50 PM UTC, ralph wrote:
    >
    > Note that the fact their cherished holy C must at some point be
    > actually implemented on nasty impure, non-portable, non-standard,
    > diverse ugly boxes and embellished with implemention features to
    > maximize the product on those boxes - gets NO toleration if ever
    > mentioned.
    >

    Depends what you are doing.
    If you're mainly interested in sending signals to items of hardware attached
    to the computer, then inevitably you need some specific understanding of
    that hardware. If you're mainly interested in bit shuffling, the code
    can and should (usually) be written in pure portable ANSI C.
    So I'm currently developing a bit shuffling algorithm for drawing graphics
    curves. The code's on my Linux box, and currently the output is via printf,
    and there's no input except for little test cases inserted into the code
    by me.
    Pretty soon I'll knock up a quick viewer in Baby X to see the curves as
    plots. Then once it's usable and doing what I want, probably go to Windows
    to make something for the client. But the eventual use could be in anything,
    maybe an iPad or a games console.
    Malcolm McLean, Jan 3, 2014
    #4
    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. Gerald
    Replies:
    0
    Views:
    713
    Gerald
    Dec 9, 2005
  2. Gerald
    Replies:
    5
    Views:
    458
  3. osmium

    Re: C library and C implement

    osmium, Jan 1, 2014, in forum: C Programming
    Replies:
    1
    Views:
    94
    Keith Thompson
    Jan 1, 2014
  4. Eric Sosman

    Re: C library and C implement

    Eric Sosman, Jan 1, 2014, in forum: C Programming
    Replies:
    0
    Views:
    103
    Eric Sosman
    Jan 1, 2014
  5. James Kuyper

    Re: C library and C implement

    James Kuyper, Jan 1, 2014, in forum: C Programming
    Replies:
    1
    Views:
    114
Loading...

Share This Page