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

c99 [options] source_file...

PARAMETERS

source_file
    One or more C source files to be compiled.

-c
    Compile and assemble, but do not link.

-o output_file
    Place the output into output_file.

-g
    Produce debugging information.

-Dname=definition
    Predefine name as a macro, with definition definition.

-Idirectory
    Add the directory to the list of directories to be searched for header files.

-Ldirectory
    Add the directory to the list of directories to be searched for -l.

-llibrary
    Search the library named library when linking.

-std=c99
    Explicitly select the C99 standard. This may be implicit when using `c99`.

[Other GCC options]
    Many other GCC options can be used with `c99`. Refer to the GCC manual for a complete list.

DESCRIPTION

The `c99` command is a compiler driver, essentially a wrapper around GCC (GNU Compiler Collection), preconfigured to compile C code adhering to the ISO C99 standard. It simplifies the process of compiling C99 programs by automatically including the necessary compiler flags and linker options. This command ensures adherence to the C99 standard, which defines features like inline functions, variable declarations within `for` loops, and the `restrict` keyword, among others.

Using `c99` streamlines the compilation process, reducing the need for developers to remember and manually specify the correct compiler flags. It promotes code portability and consistency by enforcing the C99 standard. While `c99` simplifies compilation, a solid understanding of GCC flags allows for more customized builds.

The underlying implementation depends on the specific system. It might be a symbolic link or a wrapper script. For many systems, it's simply a convenient way to invoke `gcc -std=c99`. It’s important to note that the availability and behavior of `c99` might vary slightly across different Linux distributions and systems.

CAVEATS

The specific implementation of `c99` can vary between systems. It's often a wrapper around GCC. Always check the system's manual pages for the most accurate details.

EXAMPLES

Example 1: Compiling a single C99 source file:
c99 hello.c

Example 2: Compiling and linking multiple files into an executable named 'myprogram':
c99 -o myprogram file1.c file2.c

Example 3: Compiling with debugging information:
c99 -g debug_me.c

HISTORY

The `c99` command arose as a way to easily compile C code compliant with the ISO C99 standard. As the C99 standard gained traction, compiler writers aimed to provide tools that simplified its adoption. `c99` provides a convenient alias or wrapper to the base C compiler, often GCC, with the proper flags set for C99 conformance. The widespread adoption of standards like C99 and later versions has led to increased compiler options that provide fine grained control about which version of the standard to use, diminishing its importance.

SEE ALSO

gcc(1), cc(1), make(1)

Copied to clipboard