ANSI C Compatibility

The run-time library routines are designed for compatibility with the ANSI C standard, which the Microsoft C and C++ compilers support. Functions that are ANSI C compatible are marked as ANSI in the compatibility section.

Type Checking

The major innovation of ANSI C is to permit argument-type lists in function prototypes (declarations). Given the information in the function prototype, the compiler can check later references to the function to make sure that the references use the correct number and type of arguments and the correct return value.

To take advantage of the compiler's type-checking ability, the include files that accompany the run-time library have been expanded. In addition to the definitions and declarations required by library routines, the include files now contain function declarations with argument-type lists. Several new include files have also been added. The names of these files are chosen to maximize compatibility with the ANSI C standard and with UNIX and XENIX names.

Underscores and OLDNAMES.LIB

With Microsoft C/C++, all Microsoft-specific run-time functions, constants, variables, type definitions, structures, and macros (such as, respectively, _open, _VRES16COLOR, _cpumode, _HEAPINFO, _heapinfo, and __isascii) are ANSI compatible. The Microsoft-specific run-time functions, constants, variables, type definitions, and structures begin with a single underscore; Microsoft-specific run-time macros begin with two underscores.

For compatibility with previous versions of Microsoft C, Microsoft C/C++ provides a library named OLDNAMES.LIB, which contains alias records mapping the names to the new names. For instance, open is mapped to _open.

You have to link with OLDNAMES.LIB to link Microsoft C/C++ programs with object files created by previous versions of Microsoft C. However, by default the compiler emits a library search record—the only time you must link explicitly with OLDNAMES.LIB is under one of the following situations:

Compiling with a combination of the default /Ze option (use Microsoft extensions) and the /Zl option (omit default library name from object file)

Compiling with the default /Ze option (use Microsoft extensions) and a combination of the /link option (linker-control) and the /NOD option (no default-library search)

For more information on the CL command-line options, see Chapter 13 of Environment and Tools (in the Microsoft C/C++ version 7.0 documentation set).

Note:

The compiler views a structure with both an old name and a new name as two different types; you cannot copy from an old type to a new type. Also, old prototypes that take struct pointers use the old struct names in the prototype. So, you must be consistent—match the old names for routines with the old names for the parameters and be similarly consistent with the new routine names and parameters.