C lib functions

Discussion in 'C Programming' started by Xia, May 29, 2008.

  1. Xia

    Xia Guest

    Is there a way(or where) I can see a certain C lib function, for
    example atoi, is implemented? Thanks in advance.
    Xia
     
    Xia, May 29, 2008
    #1
    1. Advertising

  2. Xia

    Guest

    On May 30, 1:37 am, Xia <> wrote:
    > Is there a way(or where) I can see a certain C lib function, for
    > example atoi, is implemented? Thanks in advance.
    > Xia

    If your implementation is open-source, you can.
    (such as glibc; <http://www.gnu.org/software/libc/libc.html>)
    There's also an excellent book by P.J. Plauger, "The Standard C
    Library", which has a complete implementation of a standard C library.
    K&R2 has an implementation of atoi in 2.7
     
    , May 29, 2008
    #2
    1. Advertising

  3. Xia

    Guest

    In article <>,
    Xia <> wrote:
    >Is there a way(or where) I can see a certain C lib function, for
    >example atoi, is implemented? Thanks in advance.


    There are several open source implementations of the standard C library
    that you can look at. (See
    <http://c-faq.com/resources/stdlibsrc.html>.)

    Be warned that most of them do several of:
    -Implement functions beyond the ones specified by the C standard
    -Call non-standard functions to do some or all of the work
    (for several standard library functions this is unavoidable)
    -Use non-portable compiler extensions
    -Use horribly ugly efficiency hacks
    These are things that make sense for library implementors to do rather
    more often than they make sense for user-programmers to do, so if your
    intention is to learn how to write good code, you may be better off
    looking at code other than implementations of the standard library.

    Note also that the language defines the interface to and behavior of
    the standard library functions, not the implementation. As long as it
    meets the requirements imposed on it by the specification, the way your
    implementation's standard library works may be entirely different from
    the one you're looking at.


    dave

    --
    Dave Vandervies dj3vande at eskimo dot com
    I think it's obvious that pretty != fit for purpose. Except that, I suppose,
    in this case pretty *is* the purpose, and rideability is relatively
    unimportant. --Eric Schwartz in the scary devil monastery
     
    , May 29, 2008
    #3
  4. Xia

    user923005 Guest

    On May 29, 3:37 pm, Xia <> wrote:
    > Is there a way(or where) I can see a certain C lib function, for
    > example atoi, is implemented? Thanks in advance.


    It's a FAQ:
    18.13: Where can I find the sources of the standard C libraries?

    A: The GNU project has a complete implementation at
    http://www.gnu.org/software/libc/. Another source (though not
    public domain) is _The Standard C Library_, by P.J. Plauger
    (see
    the Bibliography). See also questions 18.9b, 18.15c, and
    18.16.

    Also, the Microsoft compiler comes with source for the library.
    The Watcom C compiler has an open source library.

    Often, C library functions are not written in C but (rather) in
    assembly language.
     
    user923005, May 30, 2008
    #4
  5. Xia

    Rui Maciel Guest

    On Thu, 29 May 2008 15:37:31 -0700, Xia wrote:

    > Is there a way(or where) I can see a certain C lib function, for example
    > atoi, is implemented? Thanks in advance. Xia


    If you want to see how a particular standard library function is
    implemented then, as it has already been stated before, you only need to
    get your hands on any open source standard library and just dig in.

    If, on the other hand, you need to check if a certain function is
    available on your system then you can always adopt the ./configure script
    approach, which is to try to compile some minimalist test code that uses
    that particular function and check if the compilation fails or not.


    Hope this helps
    Rui Maciel
     
    Rui Maciel, May 31, 2008
    #5
    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 Yong
    Replies:
    0
    Views:
    573
    James Yong
    Sep 12, 2005
  2. Praetorian

    Need odbc32.lib odbccp32.lib

    Praetorian, Apr 20, 2006, in forum: C++
    Replies:
    1
    Views:
    1,415
    mlimber
    Apr 20, 2006
  3. Durduran
    Replies:
    10
    Views:
    557
    Durduran
    Jul 30, 2007
  4. Replies:
    3
    Views:
    2,802
  5. Christopher
    Replies:
    4
    Views:
    337
    Christopher
    Nov 1, 2007
Loading...

Share This Page