LinuxCommandLibrary

c89-gcc

Compile C code using GCC (C89 standard)

SYNOPSIS

c89-gcc [options] file...
c89-gcc options -o outfile infile

PARAMETERS

-o file
    Specify output executable or object file

-c
    Compile only, produce object file (.o)

-g
    Generate debugging information

-Olevel
    Optimization level (0-3, default 0)

-Wall
    Enable all common warnings

-pedantic
    Issue warnings for standard violations

-std=c89
    Explicitly set C89 mode (default)

-Dname[=value]
    Define preprocessor macro

-Idir
    Add include directory

-llib
    Link with library lib

-Ldir
    Add library search directory

-E
    Preprocess only, output to stdout

-S
    Compile to assembly code (.s)

-v
    Verbose output, show commands

-shared
    Create shared object file

DESCRIPTION

The c89-gcc command is a convenience wrapper script around the GNU Compiler Collection (GCC) that enforces compilation of C source code strictly according to the C89 standard (ISO/IEC 9899:1990, also known as ANSI C). It automatically invokes gcc with the -std=c89 flag, disabling C99 and later features like inline functions, long long types, // comments, and flexible array members. This ensures high portability for legacy systems and POSIX-compliant applications.

Common use cases include maintaining old codebases, cross-compilation for embedded systems, or verifying standard conformance with -pedantic. It supports all standard GCC options for optimization (-O levels), debugging (-g), warnings (-Wall), and linking libraries (-l). Output defaults to a.out or specified -o file. Preprocessor directives and macros are handled via -D and -I. Ideal for developers targeting minimal environments without modern C extensions.

CAVEATS

GCC's C89 mode includes GNU extensions unless -pedantic-errors is used; not identical to original ANSI compilers. Availability depends on distro toolchain packages.

EXAMPLE

c89-gcc -Wall -o hello hello.c
Compiles hello.c to hello executable with warnings.

c89-gcc -c -pedantic module.c
Produces strict C89 object file.

STANDARDS COMPLIANCE

Emulates ANSI X3.159-1989; use -ansi synonym for -std=c89. Test with tigcc or conformance suites.

HISTORY

Developed as part of GCC toolchain wrappers for POSIX compliance around 2000s. Mirrors POSIX c99 utility but for C89. Evolved with GCC versions; modern GCC (4+ ) provides reliable -std=c89 support.

SEE ALSO

gcc(1), c99(1), cc(1), clang(1)

Copied to clipboard