Standard C library functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • junky_fellow@yahoo.co.in

    #1

    Standard C library functions

    On what basis it is decided that a particular funtion should
    be a part of Standard C library ?

    Do I get these standard C libraries along with the C compiler ?
    Or I can use the c complier from one vendor and the standard
    C libraries from the different vendor ?

    Also, the C standard (N869), page 164, refers to "standard
    headers". Do I get these standard headers along with the
    C compiler ?

  • Cong Wang

    #2
    Re: Standard C library functions


    junky_fellow@ya hoo.co.in wrote:[color=blue]
    > On what basis it is decided that a particular funtion should
    > be a part of Standard C library ?[/color]
    Post this question in comp.std.c, you will get a better answer.[color=blue]
    > Do I get these standard C libraries along with the C compiler ?[/color]
    Not all the compilers follow the ANSI C standard,for example, M$
    compiler.Most compilers have their own libraries.If you are strict in
    the standard,try gcc with the option -ansi.[color=blue]
    > Or I can use the c complier from one vendor and the standard
    > C libraries from the different vendor ?[/color]
    Er,......[color=blue]
    > Also, the C standard (N869), page 164, refers to "standard
    > headers". Do I get these standard headers along with the
    > C compiler ?[/color]
    At most times,you do.But this also depends on your compiler.

    Comment

    • P.J. Plauger

      #3
      Re: Standard C library functions

      "Cong Wang" <xiyou.wangcong @gmail.com> wrote in message
      news:1123064055 .339596.268110@ g43g2000cwa.goo glegroups.com.. .
      [color=blue]
      > junky_fellow@ya hoo.co.in wrote:[/color]
      [color=blue][color=green]
      >> On what basis it is decided that a particular funtion should
      >> be a part of Standard C library ?[/color][/color]
      [color=blue]
      > Post this question in comp.std.c, you will get a better answer.[/color]

      There are almost as many answers as functions.
      [color=blue][color=green]
      >> Do I get these standard C libraries along with the C compiler ?[/color][/color]
      [color=blue]
      > Not all the compilers follow the ANSI C standard,for example, M$
      > compiler.[/color]

      If you meant to designate the Microsoft VC++ compiler, you
      mistakenly used a dollar sign in place of the S. You're also
      wrong. VC++ has conformed pretty closely to the C90 standard
      for many years. It gets just a couple of things wrong with C95,
      and hasn't really tried to conform to C99 yet. It also has
      quite a number of extensions that it has accreted over the
      years.

      Now, the same thing can be said of *essentially every*
      desktop C compiler available today. So what's your point?
      [color=blue]
      > Most compilers have their own libraries.[/color]

      True. Only a few not-quite-C compilers for small embedded
      processors omit most or all of the library. To fully
      conform to the C Standard, a compiler is *obliged* to
      supply a library as well.
      [color=blue]
      > If you are strict in
      > the standard,try gcc with the option -ansi.[/color]

      True. Most compilers have a similar compile-time option,
      to better check your program for conformance to the C
      Standard.
      [color=blue][color=green]
      >> Or I can use the c complier from one vendor and the standard
      >> C libraries from the different vendor ?[/color][/color]
      [color=blue]
      > Er,......[/color]

      Generally, no. There's enough machine and compiler specific
      tailoring required that one C library just won't work with
      another compiler. Dinkumware is unique in having the only
      commercial compiler-independent Standard C library, so ours
      does indeed work with quite a few compilers. It's one way to
      get all the extra C99 functions with an existing C compiler.
      (But it costs $ to license.)
      [color=blue][color=green]
      >> Also, the C standard (N869), page 164, refers to "standard
      >> headers". Do I get these standard headers along with the
      >> C compiler ?[/color][/color]
      [color=blue]
      > At most times,you do.But this also depends on your compiler.[/color]

      If you get the library, you get the headers. See above.

      P.J. Plauger
      Dinkumware, Ltd.



      Comment

      • Netocrat

        #4
        Re: Standard C library functions

        On Wed, 03 Aug 2005 06:43:40 -0400, P.J. Plauger wrote:[color=blue]
        > "Cong Wang" <xiyou.wangcong @gmail.com> wrote[color=green]
        >> junky_fellow@ya hoo.co.in wrote:[/color][/color]
        [color=blue][color=green][color=darkred]
        >>> Or I can use the c complier from one vendor and the standard
        >>> C libraries from the different vendor ?[/color][/color]
        >[color=green]
        >> Er,......[/color]
        >
        > Generally, no. There's enough machine and compiler specific
        > tailoring required that one C library just won't work with
        > another compiler. Dinkumware is unique in having the only
        > commercial compiler-independent Standard C library, so ours
        > does indeed work with quite a few compilers. It's one way to
        > get all the extra C99 functions with an existing C compiler.
        > (But it costs $ to license.)
        >[color=green][color=darkred]
        >>> Also, the C standard (N869), page 164, refers to "standard
        >>> headers". Do I get these standard headers along with the
        >>> C compiler ?[/color][/color]
        >[color=green]
        >> At most times,you do.But this also depends on your compiler.[/color]
        >
        > If you get the library, you get the headers. See above.[/color]

        Out of curiosity - I couldn't see it mentioned on your website - how much
        emphasis does the Dinkum C99 Library place on purely standards-compliant
        code? Obviously there are places where things must be tailored to an
        implementation such as header files defining types, but otherwise does the
        library ever have any specific code optimised for a particular platform
        (whether that be standard or non-standard code), or is it completely
        generic?

        And what sort of issues would prevent the library from being used with a
        particular compiler?

        Comment

        • P.J. Plauger

          #5
          Re: Standard C library functions

          "Netocrat" <netocrat@dodo. com.au> wrote in message
          news:pan.2005.0 8.03.15.26.55.8 07025@dodo.com. au...
          [color=blue]
          > On Wed, 03 Aug 2005 06:43:40 -0400, P.J. Plauger wrote:[color=green]
          >> "Cong Wang" <xiyou.wangcong @gmail.com> wrote[color=darkred]
          >>> junky_fellow@ya hoo.co.in wrote:[/color][/color]
          >[color=green][color=darkred]
          >>>> Or I can use the c complier from one vendor and the standard
          >>>> C libraries from the different vendor ?[/color]
          >>[color=darkred]
          >>> Er,......[/color]
          >>
          >> Generally, no. There's enough machine and compiler specific
          >> tailoring required that one C library just won't work with
          >> another compiler. Dinkumware is unique in having the only
          >> commercial compiler-independent Standard C library, so ours
          >> does indeed work with quite a few compilers. It's one way to
          >> get all the extra C99 functions with an existing C compiler.
          >> (But it costs $ to license.)
          >>[color=darkred]
          >>>> Also, the C standard (N869), page 164, refers to "standard
          >>>> headers". Do I get these standard headers along with the
          >>>> C compiler ?[/color]
          >>[color=darkred]
          >>> At most times,you do.But this also depends on your compiler.[/color]
          >>
          >> If you get the library, you get the headers. See above.[/color]
          >
          > Out of curiosity - I couldn't see it mentioned on your website - how much
          > emphasis does the Dinkum C99 Library place on purely standards-compliant
          > code? Obviously there are places where things must be tailored to an
          > implementation such as header files defining types, but otherwise does the
          > library ever have any specific code optimised for a particular platform
          > (whether that be standard or non-standard code), or is it completely
          > generic?[/color]

          It's pretty generic, but we have to tailor in several ways:

          -- stdarg.h and setjmp.h are *extremely* compiler specific. (In
          many cases we simply defer to the ones supplied with the compiler,
          but when we mess with these, we do so carefully.)

          -- We determine the representation of various flexible types,
          as you observe.

          -- We determine the values of numeric limits, with special care
          for twos-complement encodings.

          -- We determine the various floating-point formats. We have a set
          of about half a dozen math primitives that ensure a reasonable
          tradeoff between portability, precision, and speed. They support
          precisions from 24 bits to 113 bits, and exponent ranges from
          2^128 to 2^16384, with all IEEE special cases.

          -- We provide common nonstandard extensions to the C library,
          either by replicating them or letting them "shine through".

          --We determine the needed underlying system-call primitives
          for I/O, program startup/shutdown, etc. These are very OS
          specific.

          -- We provide multithreading support, in both C and C++, which
          also depends strongly on the underlying OS.

          There are probably other things, but that's off the top of my
          head.
          [color=blue]
          > And what sort of issues would prevent the library from being used with a
          > particular compiler?[/color]

          See above.

          P.J. Plauger
          Dinkumware, Ltd.



          Comment

          • Malcolm

            #6
            Re: Standard C library functions


            <junky_fellow@y ahoo.co.in> wrote[color=blue]
            >
            > On what basis it is decided that a particular funtion should
            > be a part of Standard C library ?
            >[/color]
            K and R decided that C would be a very slim language, with for instance no
            string handling statements beyond embedding a string literal, no IO, no
            mathematical or memory operations. All these things are provided by every
            general-purpose language, and in C they were implemented as standard
            functions.
            When ANSI standardised the language, they inherited K and R's library. They
            made a few minor alterations - for instance the va-start macro now always
            takes the last fixed parameter as an argument, malloc() takes a size_t. But
            they kept the changes to a minimum.
            Chris Torek who posts here is a member of the ANSI committee, and one of the
            people who decides such issues.[color=blue]
            >
            > Do I get these standard C libraries along with the C compiler ?
            >[/color]
            Almost always you do. The exception is C for small embedded systems, and
            also for a few larger systems like games consoles.[color=blue]
            >
            > Or I can use the c complier from one vendor and the standard
            > C libraries from the different vendor ?
            >[/color]
            Unlikely. The libraries have to be binary compatible, and there's not much
            motivation for reimplementing someone else's standard library. However Mr
            Plauger, elsethread, has made a living out of providing standard libraries
            for people needing one for some special purpose. His book is one of the must
            haves that every C programmer should read.[color=blue]
            >
            > Also, the C standard (N869), page 164, refers to "standard
            > headers". Do I get these standard headers along with the
            > C compiler ?
            >[/color]
            Yes. The headers should ship with the library. Just occasionally there won't
            be a physical file, and it will be built into the complier (you still
            #incluce <stdio.h>).



            Comment

            • lawrence.jones@ugs.com

              #7
              Re: Standard C library functions

              Malcolm <regniztar@btin ternet.com> wrote:[color=blue]
              >
              > Chris Torek who posts here is a member of the ANSI committee, and one of the
              > people who decides such issues.[/color]

              Would that he were, but alas he is not.

              -Larry Jones

              It's no fun to play games with a poor sport. -- Calvin

              Comment

              Working...