C lib functions

X

Xia

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

vippstar

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
 
D

dj3vande

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
 
U

user923005

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.
 
R

Rui Maciel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top