Introduction
The C language is traditionally a compiled language (as opposed to interpreted). The C Standard defines translation phases, and the product of applying them is a program image (or compiled program). In c11, the phases are listed in §5.1.1.2.
Filename extension | Description |
---|
.c | Source file. Usually contains definitions and code. |
.h | Header file. Usually contains declarations. |
.o | Object file. Compiled code in machine language. |
.obj | Alternative extension for object files. |
.a | Library file. Package of object files. |
.dll | Dynamic-Link Library on Windows. |
.so | Shared object (library) on many Unix-like systems. |
.dylib | Dynamic-Link Library on OSX (Unix variant). |
.exe , .com | Windows executable file. Formed by linking object files and library files. In Unix-like systems, there is no special file name extension for executable file. |
POSIX c99 compiler flags | Description |
---|
-o filename | Output file name eg. (bin/program.exe , program ) |
-I directory | search for headers in direrctory . |
-D name | define macro name |
-L directory | search for libraries in directory . |
-l name | link library libname . |
Compilers on POSIX platforms (Linux, mainframes, Mac) usually accept these options, even if they are not called c99
.
GCC (GNU Compiler Collection) Flags | Description |
---|
-Wall | Enables all warning messages that are commonly accepted to be useful. |
-Wextra | Enables more warning messages, can be too noisy. |
-pedantic | Force warnings where code violates the chosen standard. |
-Wconversion | Enable warnings on implicit conversion, use with care. |
-c | Compiles source files without linking. |
-v | Prints compilation info. |
gcc
accepts the POSIX flags plus a lot of others.
- Many other compilers on POSIX platforms (
clang
, vendor specific compilers) also use the flags that are listed above.
- See also Invoking GCC for many more options.
TCC (Tiny C Compiler) Flags | Description |
---|
-Wimplicit-function-declaration | Warn about implicit function declaration. |
-Wunsupported | Warn about unsupported GCC features that are ignored by TCC. |
-Wwrite-strings | Make string constants be of type const char * instead of char *. |
-Werror | Abort compilation if warnings are issued. |
-Wall | Activate all warnings, except -Werror , -Wunusupported and -Wwrite strings . |