Standard C library functions

J

junky_fellow

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 ?
 
C

Cong Wang

On what basis it is decided that a particular funtion should
be a part of Standard C library ?
Post this question in comp.std.c, you will get a better answer.
Do I get these standard C libraries along with the C compiler ?
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.
Or I can use the c complier from one vendor and the standard
C libraries from the different vendor ? Er,......
Also, the C standard (N869), page 164, refers to "standard
headers". Do I get these standard headers along with the
C compiler ?
At most times,you do.But this also depends on your compiler.
 
P

P.J. Plauger

(e-mail address removed) wrote:
Post this question in comp.std.c, you will get a better answer.

There are almost as many answers as functions.
Not all the compilers follow the ANSI C standard,for example, M$
compiler.

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?
Most compilers have their own libraries.

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.
If you are strict in
the standard,try gcc with the option -ansi.

True. Most compilers have a similar compile-time option,
to better check your program for conformance to the C
Standard.
Er,......

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.)
At most times,you do.But this also depends on your compiler.

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

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 
P

P.J. Plauger

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?

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.
And what sort of issues would prevent the library from being used with a
particular compiler?

See above.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 
N

Netocrat

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



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

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?
 
M

Malcolm

On what basis it is decided that a particular funtion should
be a part of Standard C library ?
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.
Do I get these standard C libraries along with the C compiler ?
Almost always you do. The exception is C for small embedded systems, and
also for a few larger systems like games consoles.
Or I can use the c complier from one vendor and the standard
C libraries from the different vendor ?
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.
Also, the C standard (N869), page 164, refers to "standard
headers". Do I get these standard headers along with the
C compiler ?
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>).
 
L

lawrence.jones

Malcolm said:
Chris Torek who posts here is a member of the ANSI committee, and one of the
people who decides such issues.

Would that he were, but alas he is not.

-Larry Jones

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

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top