Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Maths Up: ANSI C Previous: ANSI C   Contents


Converting to ANSI C

Many K&R C programs compile with an ANSI C compiler without changes. Where changes are required, the compiler will nearly always tell you. A list of differences between K&R C and ANSI C is in [7]. The most important are
Function prototyping :-
Function prototypes aren't mandatory in ANSI C, but they improve error checking. Their use enables certain ANSI C features which otherwise, for backward compatibility, are suppressed.

Parameter Passing :-

Standardisation :-
The standard include files for ANSI C are
assert.h Assertions
ctype.h Character identification
errno.h Error handling
float.h Max and Min values for floats
limits.h limits for integral types
locale.h Internationalisation info
math.h Advanced math functions
setjmp.h Non-local jump
signal.h Exception handling
stdarg.h Variable numbers of arguments
stddef.h Standard definitions
stdio.h Input/Output
stdlib.h General Utilities
string.h String Manipulation
time.h Date and Time functions

If you want to support both ANSI C and K&R C , you can use the following construction

#ifdef __STDC__
 /* ANSI code */
#else
 /* K and R code */
#endif


next up previous contents
Next: Maths Up: ANSI C Previous: ANSI C   Contents
Tim Love 2010-04-27