Name
tccmodes — TCC Compilation Modes
Built-in checking profiles
Six standard checking profiles are provided with the tool and are held as a set of startup files which are automatically included in each C source file.
-
-Xs
(strict checks) denotes strict ISO standard C with most extra checks enabled as warnings; -
-Xp
(partial checks) denotes strict ISO standard C with some extra checks enabled; -
-Xc
(conformance) denotes strict ISO standard C with no extra checks enabled; -
-Xw
(warning mode) represents awarning
oriented compilation mode. Many non-ISO standard C features are permitted with a warning. Extra checks are performed to produce warnings. -
-Xa
(standard-ish
C) denotes ISO standard C with syntatic relaxation and no extra checks; -
-Xt
(traditional C) denotes traditional (Kernighan and Ritchie) C with no extra checks.
(The modes Xc, Xa, and Xt are meant to roughly correspond to the modes found on some System V compilers.)
The default checking environment is Xc, other environments are specified by passing the name of the environment to the checker as a command line flag, e.g. the -Xs flag specifies that the Xs environment is to be used. These environments are the base checking modes and may not be combined: if more than one base mode is specified, only the final base mode is actually used - the earlier ones are ignored.
There are also two add-on
checking profiles, called nepc
(n
o e
xtra p
ortability c
hecks) and not_ansi
, which may be used to complement any base mode. The "add-on" modes may alter the status of checks set in the base mode. The nepc
mode switches off many of the checks relating to portability issues and may be specified by passing the -nepc
command line option to tcc. The not_ansi
mode supports a raft of non-ISO features and is specified using the -not_ansi
command line flag.
Compilation Modes
The built-in compilation modes are as follows:
Mode | Summary | Description |
---|---|---|
Xs | Strict checks | Strict ISO/ANSI C with most extra checks enabled as warnings |
Xp | Partial checks | Strict ISO/ANSI C with some extra checks enabled |
Xc | Conformance | Strict ISO/ANSI C with no extra checks enabled (this is default) |
Xa | ANSI-ish | ISO/ANSI C with syntactic relaxations and no extra checks |
Xt | Traditional | Traditional C with no extra checks |
The mode Xs is specified by passing the -Xs command-line option to tcc, and so on.
Base modes
The Xs
, Xp
, Xw
, Xc
, Xa
and Xt
modes are mutually incompatible and should not be used together. All other built-in mode combinations are allowed and, of course, any built-in mode can be combined with user-defined modes as described in section 2.2.
Checks marked with E are enabled to produce an error and checks marked with W are enabled to produce a warning. A blank entry implies that the check is disabled.
Check | Xs | Xp | Xw | Xc | Xa | Xt | |
---|---|---|---|---|---|---|---|
Value of __STDC__ | 1 | 1 | 1 | 1 | 1 | 0 | |
ISO C rules for integer literals | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | |
ISO C rules for integer promotions | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | |
assignments as conditional statements | W | ||||||
bitfield overflow | E | E | W | E | E | ||
block level static function | E | E | W | E | |||
character escape overflow | E | E | W | E | E | ||
sign of char [a] | ∓ | ∓ | ∓ | ∓ | ∓ | ∓ | |
char * as generic pointer | E | E | W | E | E | ||
complete struct/union analysis | W | W | |||||
conditional lvalues | E | E | E | E | |||
constant conditional control statements | W | ||||||
conversion analysis: | |||||||
(int → enum implicit) | W | ||||||
(int → enum explicit) | |||||||
(int → enum implicit) | W | W | |||||
(int ↔ pointer explicit) | W | W | W | ||||
(int ↔ pointer implicit) | E | E | E | E | |||
(pointer → pointer explicit) | W | W | |||||
(pointer → pointer implicit) | E | E | E | E | E | ||
directive used as macro argument | W | ||||||
directive assert | E | E | W | E | |||
directive file | E | E | W | E | |||
directive ident | E | E | W | E | |||
directive unassert | E | E | W | E | |||
directive weak | E | E | W | E | |||
discard analysis: | |||||||
(function return) | W | W | |||||
(static) | W | W | |||||
(value) | W | W | |||||
$ used as character | E | ||||||
enum switch analysis | W | ||||||
extra , at end of enum lists | E | E | W | E | |||
extra ... in function prototypes | E | E | W | E | |||
extra ; after external declarations | E | E | W | E | |||
extra ; after conditional statements | W | ||||||
extra int types for bitfields | E | E | W | E | |||
extra macro definitions | E | E | E | E | |||
extra type name definitions | E | E | W | E | |||
fall into case | W | W | |||||
forward enum declarations | |||||||
function pointer ↔ pointer conversions | W | W | E | E | E | ||
... as argument in function call | E | E | E | E | E | E | |
unify the tag namespace | E | E | W | E | W | W | |
implicit function declaration | E | W | W | ||||
implicit int type for external declaration | E | E | E | E | W | ||
implicit int type for function return | E | W | W | ||||
incompatible interface definition | E | W | W | W | |||
incompatible linkage | W | W | |||||
incompatible promoted function argument | E | E | W | E | E | E | |
incompatible type qualifier | E | E | W | E | |||
incompatible void return | W | W | W | ||||
incomplete type used as object type | E | E | W | E | |||
indented # directive | W | W | |||||
indented directive after # | |||||||
initialization of automatic struct /union | W | ||||||
integer operator analysis | W | ||||||
integer overflow analysis | W | ||||||
linkage resolution: | W | W | W | W | W | W | |
external | |||||||
internal | Y | Y | Y | Y | Y | Y | |
long long type: | E | E | E | E | E | E | |
implemented as long | |||||||
implemented as long long | |||||||
nested comment analysis | W | ||||||
no directive/new line after identifier | E | E | W | E | |||
no external declarations present | E | E | W | E | |||
no identifier after # | E | E | W | E | |||
no new line at end of file | E | E | W | E | E | ||
operator precedence analysis | W | ||||||
prototype use: | W | ||||||
prototype analysis | E | E | E | E | |||
weak prototype use: | |||||||
weak prototype analysis | E | E | W | ||||
name length limit on identifiers | |||||||
text after directive | E | E | W | E | |||
printf /scanf string checking | E | E | W | ||||
unify external linkage | E | E | W | E | |||
unify incompatible string literal | E | E | W | E | E | ||
unknown directive | E | E | W | E | |||
unknown escape | E | E | W | E | W | W | |
unknown pragma | W | W | W | W | W | ||
unnamed struct /union type | E | E | E | E | E | ||
unmatched quotes | W | W | |||||
unreachable code | W | W | W | ||||
variable analysis | W | W | |||||
variable hiding analysis | W | ||||||
variable initialization | E | E | E | E | |||
weak macro equality | E | E | W | E | |||
writeable string literal | W | W |
- [a]
a plain
char
is of unspecified sign
nepc
and not_ansi
modes
These modes modify the base environment.
The nepc
environment switches off most of the extra portability checking. It is specified by passing the -nepc
option to tcc.
Printf String Checking OFF
Pragma Profile:
#pragma TenDRA conversion analysis off #pragma TenDRA weak prototype analysis off #pragma TenDRA compatible type : char * == void * : allow #pragma TenDRA function pointer as pointer allow #pragma TenDRA character escape overflow allow #pragma TenDRA no nline after file end allow #pragma TenDRA bitfield overflow allow
The not_ansi
environment provides support for a range of non-ansi dialect features. It is specified by passing the -not_ansi
option to tcc.
Pragma Profile:
#pragma TenDRA linkage resolution : (internal) on #pragma TenDRA unify external linkage on #pragma TenDRA directive assert allow #pragma TenDRA directive file allow #pragma TenDRA directive ident allow #pragma TenDRA directive unassert allow #pragma TenDRA directive weak allow #pragma TenDRA compatible type : char * == void * : allow #pragma TenDRA conditional lvalue allow #pragma TenDRA extra ; allow #pragma TenDRA extra bitfield int type allow #pragma TenDRA extra type definition allow #pragma TenDRA ignore struct/union/enum tag on #pragma TenDRA implicit int type for external declaration allow #pragma TenDRA implicit int type for function return allow #pragma TenDRA no external declaration allow #pragma TenDRA text after directive allow #pragma TenDRA unknown escape allow #pragma TenDRA unknown pragma allow #pragma TenDRA weak macro equality allow #pragma TenDRA extra ... allow #pragma TenDRA extra , allow #pragma TenDRA incomplete type as object type allow #pragma TenDRA dollar as ident allow #pragma TenDRA variable initialization allow #pragma TenDRA extra macro definition allow #pragma TenDRA incompatible type qualifier allow #pragma TenDRA no directive/nline after ident allow #pragma TenDRA unknown directive allow #pragma TenDRA no ident after # allow #pragma TenDRA block function static allow #pragma TenDRA unknown struct/union allow