LinuxCommandLibrary

c99

Compile C source code

TLDR

Compile source file(s) and create an executable

$ c99 [file.c]
copy

Compile source file(s) and specify the executable [o]utput filename
$ c99 -o [executable_name] [file.c]
copy

Compile source file(s) and create object file(s)
$ c99 -c [file.c]
copy

Compile source file(s), link with object file(s), and create an executable
$ c99 [file.c] [file.o]
copy

SYNOPSIS

Since c99 is a programming language standard and not a direct command-line executable, it is invoked indirectly via a C compiler. The most common synopsis involves specifying the standard to a compiler like gcc:

gcc -std=c99 [options] file...

Here, file... refers to one or more C source code files (e.g., `program.c`). The [options] represent various compiler flags that control compilation, linking, optimization, and warnings.

PARAMETERS

N/A
    c99 itself is a programming language standard, not a command-line executable. Therefore, it does not accept direct command-line parameters. Its features are enabled and utilized via flags passed to C compilers like gcc or clang. The primary flag to enable C99 features is typically -std=c99.

DESCRIPTION

c99 is not a standalone Linux command or executable utility in the traditional sense, but rather a widely adopted standard for the C programming language, formally known as ISO/IEC 9899:1999.

It defines the syntax, semantics, and libraries for C programs, providing a common ground for compilers and developers. Key features introduced in C99 include long long integers, variable-length arrays (VLAs), restrict type qualifier, _Bool type for booleans, inline functions, designated initializers, compound literals, and flexible array members.

On Linux systems, c99 functionality is typically accessed through C compilers like GCC (GNU Compiler Collection) or Clang. Developers use compiler flags, most notably -std=c99, to instruct the compiler to adhere to this specific version of the C standard during compilation. This ensures that the code written uses features available in C99 and that the compiler applies the rules defined by the standard, aiding in portability and consistent behavior across different systems that support the standard.

CAVEATS

While c99 defined many significant features, not all compilers fully implement every aspect of the standard, or they might implement them with extensions. Some features, like Variable Length Arrays (VLAs), became optional in later C standards (C11, C17), leading to varying levels of support or warnings from newer compilers when compiling C99 code. Developers should consult compiler documentation for exact compliance details. Furthermore, mixing C99 code with C++ code (especially older C++ standards) can sometimes lead to compatibility issues.

KEY C99 FEATURES

Some notable features introduced or standardized in c99 include:
long long: A 64-bit integer type for extended range.
Variable-Length Arrays (VLAs): Arrays whose size can be determined at runtime.
restrict keyword: A type qualifier indicating that a pointer is the sole means of access to a data object, enabling aggressive optimizations.
_Bool type: A true boolean type (`true` and `false` macros are provided in <stdbool.h>).
inline functions: Suggests to the compiler to integrate the function body directly into the call site.
Designated Initializers: Allows initializing specific elements of an array or members of a struct by name.
Compound Literals: Unnamed objects that can be used where an object of a particular type is expected.
Flexible Array Members: Allows structs to contain a dynamically sized array at the end.

C99 LIBRARIES AND HEADERS

c99 also introduced new standard library headers and functions, enhancing C's capabilities. Examples include <stdbool.h> for boolean types, <stdint.h> for fixed-width integer types (e.g., int32_t, uint64_t), <inttypes.h> for integer format string macros, <complex.h> for complex number arithmetic, and enhancements to existing headers like <math.h> for new mathematical functions.

HISTORY

The c99 standard was developed by the ISO (International Organization for Standardization) and IEC (International Electrotechnical Commission) and published in 1999 as ISO/IEC 9899:1999. It was a significant revision to the original C standard, C89 (also known as C90 or ANSI C), which was published in 1990. The motivation behind c99 was to address real-world programming practices, incorporate features that were already widely used as extensions in popular compilers (like GCC), and fix ambiguities or limitations in the C89 standard. It aimed to make C more modern and suitable for a wider range of applications. While widely adopted, it was later superseded by the c11 standard (ISO/IEC 9899:2011) and subsequently c17 (ISO/IEC 9899:2018), which introduced new features and deprecated or made optional some C99 features (e.g., VLAs).

SEE ALSO

gcc(1), clang(1), c89, c11, c17, posix(0)

Copied to clipboard