On May 30, 1:37 am, Xia <ningx...@gmail .comwrote:
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
In article <9f6d4611-b2a2-4184-a8da-681582f469e2@k3 0g2000hse.googl egroups.com>,
Xia <ningx005@gmail .comwrote:
>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
On May 29, 3:37 pm, Xia <ningx...@gmail .comwrote:
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.
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.
Comment