Libraries:
The C programming language
uses libraries as its primary method of extension. In C, a library is a set of
functions contained within a single "archive" file. Each library
typically has a header file, which contains the prototypes of the functions
contained within the library that may be used by a program, and declarations of
special data types and macro symbols used with these functions. In order for a
program to use a library, it must include the library's header file, and the
library must be linked with the program, which in many cases requires compiler
flags (e.g., -lm, shorthand for "link the math library").
The most common C library is the C standard library, which is specified
by the ISO and ANSI C standards and comes with every C implementation
(implementations which target limited environments such as embedded systems may
provide only a subset of the standard library). This library supports stream
input and output, memory allocation, mathematics, character strings, and time
values. Several separate standard headers (for example, stdio.h) specify the
interfaces for these and other standard library facilities.
Another common set of C library functions
are those used by applications specifically targeted for Unix and Unix-like
systems, especially functions which provide an interface to the kernel. These
functions are detailed in various standards such as POSIX and the Single UNIX
Specification.
Since many programs have been written in C, there are a wide variety of
other libraries available. Libraries are often written in C because C compilers
generate efficient object code; programmers then create interfaces to the
library so that the routines can be used from higher-level languages like Java,
Perl, and Python.
Language tools:
This section
needs additional citations for verification. Please help improve this article
by adding citations to reliable sources. Unsourced material may be challenged
and removed. (July 2014) (Learn how and when to remove this template message)
A number of
tools have been developed to help C programmers find and fix statements with
undefined behavior or possibly erroneous expressions, with greater rigor than
that provided by the compiler. The tool lint was the first such, leading to
many others.
Automated
source code checking and auditing are beneficial in any language, and for C
many such tools exist, such as Lint. A common practice is to use Lint to detect
questionable code when a program is first written. Once a program passes Lint,
it is then compiled using the C compiler. Also, many compilers can optionally
warn about syntactically valid constructs that are likely to actually be
errors. MISRA C is a proprietary set of guidelines to avoid such questionable
code, developed for embedded systems.[34]
There are also
compilers, libraries, and operating system level mechanisms for performing
actions that are not a standard part of C, such as bounds checking for arrays,
detection of buffer overflow, serialization, dynamic memory tracking, and
automatic garbage collection.
Tools such as Purify or Valgrind and linking with libraries containing
special versions of the memory allocation functions can help uncover runtime
errors in memory usage.
The End….
From
@mit….
No comments:
Post a Comment