04-10-2025, 10:29 AM
The main changes between the C89 (also known as ANSI C or C90) and C99 standards of the C programming language are significant and aim to improve functionality, flexibility, and compatibility with other languages. Here is a list of the most important changes:
1. New Data Types:
Five new keywords were added to the language:
The C++ style of single-line comments using
was adopted.
4. Flexible Variable Declarations:
In C89, variable declarations had to appear at the beginning of a block (before any statement). C99 allows declaring variables anywhere within a block, just before they are used for the first time.
5. Variable Length Arrays (VLAs):
C99 allows the declaration of arrays whose size is not a constant at compile time. The size can be determined at runtime. These arrays can be automatic (on the stack) or can be a function parameter.
6.
Loops with Declaration in Initialization:
C99 allows declaring the control variable directly in the initialization of the
loop, for example:
. The scope of this variable is limited to the loop.
7. New Library Functions and Headers:
Several new functions were added to the standard library, along with new headers:
C99 allows initializing specific members of structures and unions by their name, instead of relying on the order of the members. For example:
. Designated initialization is also allowed for arrays.
11. Compound Literals:
C99 introduces the possibility of creating values of type struct, union, or array "on the fly" without needing to declare a named variable. For example:
.
12. Defined Behavior for Division and Modulo with Negative Operands:
In C89, the result of division and modulo with negative operands depended on the implementation. C99 specifies that the result of the division is always truncated towards zero, and the sign of the result of the modulo operator is the same as the sign of the first operand.
13. Extended Identifiers:
C99 relaxes the restrictions on the length of identifiers. C89 required compilers to remember the first 31 characters for internal identifiers and only the first 6 characters (case-insensitive) for names with external linkage. C99 increases these limits to 63 characters for internal identifiers and 31 characters (case-sensitive) for names with external linkage.
In summary, C99 introduced many features that made the C language more powerful, flexible, and suitable for a wider range of applications, bringing it closer in some aspects to languages like C++. Although C99 was a significant advancement, other standards such as C11 and C17/C18 were subsequently published, which introduced even more improvements.
1. New Data Types:
: An integer type with at least 64 bits, providing a larger range for integer values.
: A boolean type that can take the values 0 (false) or 1 (true). A macro
is defined in
that expands to
, along with the macros
and
.
- Complex Numbers: The types
and
(optional) are introduced, along with the
header to support complex number arithmetic.
Five new keywords were added to the language:
- : To suggest to the compiler that it should perform inline expansion of a function to improve performance.
- : A type qualifier for pointers that indicates that the pointer is the only way to access the pointed object within a certain scope, allowing the compiler to perform optimizations.
- : Already mentioned in the data types.
- : Already mentioned in the data types.
- : Already mentioned in the data types.
The C++ style of single-line comments using
was adopted.
4. Flexible Variable Declarations:
In C89, variable declarations had to appear at the beginning of a block (before any statement). C99 allows declaring variables anywhere within a block, just before they are used for the first time.
5. Variable Length Arrays (VLAs):
C99 allows the declaration of arrays whose size is not a constant at compile time. The size can be determined at runtime. These arrays can be automatic (on the stack) or can be a function parameter.
6.
Loops with Declaration in Initialization:
C99 allows declaring the control variable directly in the initialization of the
loop, for example:
. The scope of this variable is limited to the loop.
7. New Library Functions and Headers:
Several new functions were added to the standard library, along with new headers:
- : Defines macros for the boolean type (
,
,
).
- : Defines integer types with specified widths (such as
,
).
- : Provides support for complex numbers.
- : Defines type-generic macros for mathematical functions.
- : Defines functions for formatting fixed-width integers.
- : Defines macros for logical and relational operators (such as
instead of
).
- : Provides support for controlling the floating-point environment.
- Variadic Macros: C99 allows the definition of macros that can take a variable number of arguments, similar to functions with ellipses.
Predefined Identifier: A predefined identifier that contains the name of the current function as a string.
- Clearer rules were defined for implicit conversions between arithmetic types.
- Support for floating-point arithmetic was improved, including better compliance with the IEEE 754 standard.
C99 allows initializing specific members of structures and unions by their name, instead of relying on the order of the members. For example:
. Designated initialization is also allowed for arrays.
11. Compound Literals:
C99 introduces the possibility of creating values of type struct, union, or array "on the fly" without needing to declare a named variable. For example:
.
12. Defined Behavior for Division and Modulo with Negative Operands:
In C89, the result of division and modulo with negative operands depended on the implementation. C99 specifies that the result of the division is always truncated towards zero, and the sign of the result of the modulo operator is the same as the sign of the first operand.
13. Extended Identifiers:
C99 relaxes the restrictions on the length of identifiers. C89 required compilers to remember the first 31 characters for internal identifiers and only the first 6 characters (case-insensitive) for names with external linkage. C99 increases these limits to 63 characters for internal identifiers and 31 characters (case-sensitive) for names with external linkage.
In summary, C99 introduced many features that made the C language more powerful, flexible, and suitable for a wider range of applications, bringing it closer in some aspects to languages like C++. Although C99 was a significant advancement, other standards such as C11 and C17/C18 were subsequently published, which introduced even more improvements.
