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.

(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 (no extra portability checks) 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:

XsStrict checksStrict ISO/ANSI C with most extra checks enabled as warnings
XpPartial checksStrict ISO/ANSI C with some extra checks enabled
XcConformanceStrict ISO/ANSI C with no extra checks enabled (this is default)
XaANSI-ishISO/ANSI C with syntactic relaxations and no extra checks
XtTraditionalTraditional 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.

Value of __STDC__111110
ISO C rules for integer literals
ISO C rules for integer promotions
assignments as conditional statementsW
bitfield overflowEEWEE
block level static functionEEWE
character escape overflowEEWEE
sign of char [a]
char * as generic pointerEEWEE
complete struct/union analysisWW
conditional lvaluesEEEE
constant conditional control statementsW
conversion analysis:
(intenum implicit)W
(intenum explicit)
(intenum implicit)WW
(int ↔ pointer explicit)WWW
(int ↔ pointer implicit)EEEE
(pointer → pointer explicit)WW
(pointer → pointer implicit)EEEEE
directive used as macro argumentW
directive assertEEWE
directive fileEEWE
directive identEEWE
directive unassertEEWE
directive weakEEWE
discard analysis:
(function return)WW
$ used as characterE
enum switch analysisW
extra , at end of enum listsEEWE
extra ... in function prototypesEEWE
extra ; after external declarationsEEWE
extra ; after conditional statementsW
extra int types for bitfieldsEEWE
extra macro definitionsEEEE
extra type name definitionsEEWE
fall into caseWW
forward enum declarations
function pointer ↔ pointer conversionsWWEEE
... as argument in function callEEEEEE
unify the tag namespaceEEWEWW
implicit function declarationEWW
implicit int type for external declarationEEEEW
implicit int type for function returnEWW
incompatible interface definitionEWWW
incompatible linkageWW
incompatible promoted function argumentEEWEEE
incompatible type qualifierEEWE
incompatible void returnWWW
incomplete type used as object typeEEWE
indented # directiveWW
indented directive after #
initialization of automatic struct/unionW
integer operator analysisW
integer overflow analysisW
linkage resolution:WWWWWW
long long type:EEEEEE
implemented as long
implemented as long long
nested comment analysisW
no directive/new line after identifierEEWE
no external declarations presentEEWE
no identifier after #EEWE
no new line at end of fileEEWEE
operator precedence analysisW
prototype use:W
prototype analysisEEEE
weak prototype use:
weak prototype analysisEEW
name length limit on identifiers
text after directiveEEWE
printf/scanf string checkingEEW
unify external linkageEEWE
unify incompatible string literalEEWEE
unknown directiveEEWE
unknown escapeEEWEWW
unknown pragmaWWWWW
unnamed struct/union typeEEEEE
unmatched quotesWW
unreachable codeWWW
variable analysisWW
variable hiding analysisW
variable initializationEEEE
weak macro equalityEEWE
writeable string literalWW
Table 1. Error levels per mode
  1. [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