-fsyntax-only -pedantic -pedantic-errors -w
For All these use -W prefix
all includes options in this color
comment
aggregate-return
cast-align
cast-qual
char-subscripts
conversion no-deprecated-declarations
disabled-optimization no-div-by-zero
no-endif-labels
error
error-implicit-function-declaration
implicit-function-declaration
extra
fatal-errors float-equal format format=2
no-format-extra-args
format-nonliteral format-security format-y2k implicit
implicit-int import no-import init-self inline
no-invalid-offsetof
invalid-pch
larger-than-len long-long
main missing-braces missing-field-initializers missing-format-attribute
missing-include-dirs missing-noreturn most(APPLE ONLY) no-multichar nonnull packed
padded parentheses
redundant-decls
return-type
pointer-arith
no-int-to-pointer-cast
no-pointer-to-int-cast
sequence-point shadow
stack-protector
sign-compare strict-aliasing
strict-aliasing=2 switch switch-default switch-enum
system-headers
trigraphs
undef
uninitialized unknown-pragmas unreachable-code
unused unused-function
unused-label unused-parameter unused-value unused-variable
write-strings
variadic-macros
|
C-only Warning Options
|
---|
bad-function-cast missing-declarations declaration-after-statement
missing-prototypes nested-externs
old-style-definition strict-prototypes
traditional no-discard-qual no-pointer-sign
| | |
|
Debugging Options
-dletters -dumpspecs -dumpmachine -dumpversion
-fdump options
|
---|
-unnumbered
-translation-unit[-n]
-class-hierarchy[-n] -ipa-all -ipa-cgraph -tree-all
-flimit-debug-info -feliminate-dwarf2-dups
-feliminate-unused-debug-types -feliminate-unused-debug-symbols -fmem-report -fopt-diary
-fprofile-arcs -ftree-based-profiling -frandom-seed=string -fsched-verbose=n -ftest-coverage
-ftime-report -fvar-tracking
-g -glevel -gcoff -gdwarf-2 -ggdb -gstabs -gstabs+ -gvms
-gxcoff -gxcoff+ -p -pg -print-file-name=library -print-libgcc-file-name
-print-multi-directory -print-multi-lib -print-prog-name=program -print-search-dirs -Q
-save-temps -time
Optimization Options
all prefixed with -f
machine dependent options
| alignunctions=n align-jumps=n align-labels=n align-loops=n align-loops-max-skip=n
align-jumps-max-skip=n bounds-check mudflap mudflapth mudflapir branch-probabilities
profile-values vpt branch-target-load-optimize branch-target-load-optimize2
btr-bb-exclusive caller-saves cprop-registers create-profile cseollow-jumps
cse-skip-blocks cx-limited-range data-sections delayed-branch
delete-null-pointer-checks expensive-optimizations fast-math float-store force-addr
force-mem function-sections gcse gcse-lm gcse-sm gcse-las gcse-after-reload
loop-optimize crossjumping if-conversion if-conversion2 inlineunctions
inline-limit=n keep-inlineunctions keep-static-consts merge-constants
merge-all-constants modulo-sched no-branch-count-reg no-default-inline no-defer-pop
loop-optimize2 move-loop-invariants no-function-cse no-guess-branch-probability
no-inline no-math-errno no-peephole no-peephole2 unsafe-math-optimizations
finite-math-only no-trapping-math no-zero-initialized-in-bss -mstackrealign
omitrame-pointer optimize-register-move optimize-sibling-calls prefetch-loop-arrays
profile-generate profile-use regmove rename-registers reorder-blocks
reorder-blocks-and-partition reorderunctions rerun-cse-after-loop rerun-loop-opt
rounding-math schedule-insns schedule-insns2 no-sched-interblock no-sched-spec
sched-spec-load sched-spec-load-dangerous sched-stalled-insns=n -sched-stalled-insns-dep=n
sched2-use-superblocks sched2-use-traces reschedule-modulo-scheduled-loops signaling-nans
single-precision-constant speculative-prefetching stack-protector stack-protector-all
strength-reduce strict-aliasing tracer thread-jumps unroll-all-loops unroll-loops
peel-loops split-ivs-in-unroller unswitch-loops variable-expansion-in-unroller tree-pre
tree-ccp tree-dce tree-loop-optimize tree-loop-linear tree-loop-im tree-loop-ivcanon
ivopts tree-dominator-opts tree-dse tree-copyrename tree-ch tree-sra tree-ter
tree-lrs treere tree-vectorize use-profile web scalar-evolutions all-data-deps
--param name=value -O -O0 -O1 -O2 -O3 -Os -Oz ast
Preprocessor Options
|
---|
-Aquestion=answer -A-question[=answer] -C -dD -dI -dM -dN -Dmacro[=defn] -E -H -idirafter
dir -include file -imacros file -iprefix file -iwithprefix dir -iwithprefixbefore dir -isystem
dir -M -MM -MF -MG -MP -MQ -MT -nostdinc -P -fworking-directory -remap -trigraphs
-undef -Umacro -Wp,option -Xpreprocessor option
Assembler Option
|
---|
-Wa,option -Xassembler option
Linker Options
|
---|
object-file-name -llibrary -nostartfiles -nodefaultlibs -nostdlib -pie -s -static
-static-libgcc -shared -shared-libgcc -symbolic -Wl,option -Xlinker option -u symbol
-Wl,-Map=$(@:.out=.map) makefile.common
GCC linker
Directory Options
|
---|
-Bprefix -Idir -iquotedir -Ldir -specs=file -I-
Target Options
|
---|
-V version -b machine
Machine Dependent Options
ARM Options
All requitre -m prefix
apcs-frame no-apcs-frame abi=name apcs-stack-check no-apcs-stack-check
apcs-float no-apcs-float apcs-reentrant no-apcs-reentrant sched-prolog
no-sched-prolog little-endian big-endian words-little-endian float-abi=name
soft-float hard-float fpe thumb-interwork no-thumb-interwork cpu=name arch=name
fpu=name structure-size-boundary=n abort-on-noreturn long-calls no-long-calls
single-pic-base no-single-pic-base pic-register=reg nop-fun-dllimport
cirrus-fix-invalid-insns no-cirrus-fix-invalid-insns poke-function-name thumb arm
tpcs-frame tpcs-leaf-frame caller-super-interworking callee-super-interworking
+++
Darwin Options
|
---|
-all_load -allowable_client -arch -arch_errors_fatal -arch_only -bind_at_load
-bundle -bundle_loader -client_name -compatibility_version -current_version -dead_strip
-dependency-file -dylib_file -dylinker_install_name -dynamic -dynamiclib
-exported_symbols_list -filelist-flat_namespace -force_cpusubtype_ALL -force_flat_namespace
-headerpad_max_install_names -iframework -image_base -init -install_name -keep_private_externs
-multi_module -multiply_defined -multiply_defined_unused -noall_load
-no_dead_strip_inits_and_terms -nofixprebinding -nomultidefs -noprebind -noseglinkedit
-pagezero_size -prebind -prebind_all_twolevel_modules -private_bundle -read_only_relocs
-sectalign -sectobjectsymbols -whyload -seg1addr -sectcreate -sectobjectsymbols -sectorder
-segaddr -segs_read_only_addr -segs_read_write_addr -seg_addr_table -seg_addr_table_filename
-seglinkedit -segprot -segs_read_only_addr -segs_read_write_addr -single_module -static
-sub_library -sub_umbrella -twolevel_namespace -umbrella -undefined -unexported_symbols_list
-weak_reference_mismatches -whatsloaded -F -gused -gfull -mmacosx-version-min=version -mkernel
-mone-byte-bool
| | | |
---|
| | | | | | |
---|
| | | | | | |
Code Generation Options
-fcall-saved-reg -fcall-used-reg -ffixed-reg -fexceptions -fnon-call-exceptions
-funwind-tables -fasynchronous-unwind-tables -finhibit-size-directive -finstrument-functions
-fno-common -fno-ident -fpcc-struct-return -fpic -fPIC -fpie -fPIE -freg-struct-return
-fshared-data -fshort-enums -fshort-double -fshort-wchar -fverbose-asm -fpack-struct[=n]
-fstack-check -fstack-limit-register=reg -fstack-limit-symbol=sym -fargument-alias
-fargument-noalias -fargument-noalias-global -fleading-underscore -ftls-model=model -ftrapv
-fwrapv -fbounds-check -fvisibility
| | | | | | |
Compilation involves stages: preprocessing, compilation proper, assembly and linking, always in that order.
GCC is capable of preprocessing and compiling several files either into
several assembler input files, or into one assembler input file; then each assembler input file
produces an object file, and linking combines all the object files (those newly compiled, and those
specified as input) into an executable file.
suffix determines what kind of compilation is done:
file.cC must be preprocessed.
| file.iC not be preprocessed.
| file.iiC++ should not be preprocessed.
| file.mObjective-C . link with the libobjc library to make an Objective-C program work.
| file.miObjective-C should not be preprocessed.
| file.mm, file.M
Objective-C++ source code. link with the libobjc library to make an
Objective-C++ program work. Note that .M refers to a literal capital M.
| file.miiObjective-C++ should not be preprocessed.
| file.hC, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header.
| file.cc, file.cp, file.cxx, file.cpp, file.CPP, file.c++, file.C
C++ source code which must be preprocessed. Note that in .cxx, the last two letters must both be
literally x. Likewise, .C refers to a literal capital C.
| file.mm, file.M Objective-C++ must be preprocessed.
| file.miiObjective-C++ should not be preprocessed.
| file.hh, file.H C++ header file to be turned into a precompiled header.
| file.f
file.for, file.FORFortran should not be preprocessed.
| file.F
file.fpp
file.FPPFortran must be preprocessed (with the traditional preprocessor).
| file.rFortran must be preprocessed with a RATFOR preprocessor (not included with GCC).
| file.f90
file.f95Fortran 90/95 should not be preprocessed.
| file.adsAda contains a library unit declaration (a declaration of a package,
subprogram, or generic, or a generic instantiation), or a library unit renaming declaration (a
package, generic, or subprogram renaming declaration). specs.
| file.adbAda library unit body (a subprogram or package body). bodies.
| file.sAssembler Apple's version of GCC runs the preprocessor on these files as well as those ending in .S.
| file.SAssembler which must be preprocessed.
| | | | | | | | | | | | | | | | | | | | | | | |
other An object file to be fed straight into linking.
Any file name with no recognized suffix is treated this way.
Specify the input language explicitly with the -x option:
-x language
Specify explicitly the language for the following input files (rather than letting the compiler
choose a default based on the file name suffix).
This option applies to all following input files until the next -x option.
c c-header c-cpp-output
c++ c++-header c++-cpp-output
objective-c objective-c-header objective-c-cpp-output
objective-c++ objective-c++-header objective-c++-cpp-output
assembler assembler-with-cpp
ada
f77 f77-cpp-input ratfor
f95
java
treelang
| -x none |
Turn off any specification of a language, so that subsequent files are handled according to their
file name suffixes (as they are if -x has not been used at all).
| -ObjC
| -ObjC++ |
As with -x objective-c and -x objective-c++ but affect only the choice of
compiler for files already identified as source files.
| -arch arch |
Compile for the specified target architecture arch. The allowable values are i386, ppc and ppc64.
Multiple options work, and direct the compiler to produce universal binaries
including object code for each architecture specified with -arch. This option only works if
assembler and libraries are available for each architecture specified.
|
-fsave-repository=file Save debug info in separate object file, only with PCH in -gfull
| -pass-exit-codes returns with highest error produced by any phase .
Default returns 1 if any phase of the compiler returns a nonsuccess return code.
To execute only some of the stages of compilation, use -x (or filename suffixes) to tell gcc
where to start, and one of the options -c, -S, or -E where to stop.
Some combinations (for example, -x cpp-output -E ) instruct gcc to do nothing .
| -c Compile or assemble but do not link.
By default, the object file name is made by replacing the suffix with .o.
Unrecognized input files, not requiring compilation or assembly, are ignored
| -S Stop after the stage of compilation proper; do not assemble.
The output is assembler code for each non-assembler source .
By default, the assembler file name is made by replacing the suffix with .s.
Input files that don't require compilation are ignored.
| -E Stop after the preprocessing stage; do not run the compiler .
The output is preprocessed source code, to standard output.
This allows viewing pre-processor substituions.
| -o file Place output in file .
The default is for an - executable file in a.out,
- the object file for
source.suffix in source.o,
- assembler file in source.s,
- precompiled header file in
source.suffix.gch,
- preprocessed C source on standard output.
| -v Include (on stderr ) commands executed to run the stages of compilation,
the version of the compiler driver, preprocessor and compiler.
As of 11/16/21 Monterey:Configured with:
--prefix=/Library/Developer/CommandLineTools/usr
--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
| -### Like -v except the commands are not executed and command arguments are quoted.
Useful for shell scripts to capture the driver-generated command lines.
| -pipe Use pipes rather than temporary files between the various stages of compilation.
| -combine
If you are compiling multiple source files, this option tells the driver to
pass all the source files to the compiler at once (for those languages for which the compiler can handle this).
This allows InterModule Analysis (IMA) to be performed by the compiler for C.
Passing source files for multiple languages to the driver, using this option, causes he driver will invoke the compiler(s)
that support IMA once each,
passing each compiler all the source files appropriate for it.
For those languages that do not
support IMA this will be ignored, and the compiler will be invoked once for each source
file in that language.
With -save-temps the compiler will generate multiple pre-processed files (one for each source file),
but only one (combined) .o or .s file.
| --help output (on the stdout) command line options .
With -v passed to the processes invoked , they can display the command line options.
With -v -Wextra command line options which have no documentation will also be displayed.
| --target-help output (stout) a description of target specific command line options for each tool.
| --version the version number and copyrights of the invoked GCC.
| | | | | | | | | | | | | | |
Compiling C++ Programs
C++ source files use suffixes .C, .cc, .cpp, .CPP, .c++, .cp, or .cxx; C++
header files often use .hh or .H ; and
preprocessed C++ files use the suffix .ii .
GCC recognizes files with these names and compiles them as C++
gcc does not add the C++ library.
g++ calls GCC and treats .c, .h and .i files as C++ source files
links them with the C++ library. useful when precompiling a C header file
with a .h extension for use in C++ compilations. , g++ may have a synonom c++.
|
Options Controlling C Dialect
-ansi In C mode, support all ISO C90 programs. In C++ mode, remove GNU extensions that conflict with ISO C++.
Turns off features of GCC that are incompatible with ISO C90
such as the "asm" and "typeof" keywords, and
predefined macros such as "unix" and "vax"
enables trigraph .
For the C compiler, disables C++ style // comments and inline
keywords "__asm__", "__extension__", "__inline__" and "__typeof__"
and predefined macros such as "__unix__" and "__vax__" are always available,
Does not cause non-ISO programs to be rejected .
With -pedantic causes non-ISO programs to be rejected .
The macro __STRICT_ANSI__ is edefined .
This causes some header files to refrain from declaring certain functions or defining certain macros that
the ISO standard doesn't call for; this avoids interfering with programss that use these names.
Functions normally built (such as "alloca" and "ffs") are not built-in functions.
| -std=standard Define the standard when compiling C or C++.
c89
| iso9899:1990
| ISO C90 (same as -ansi).
| iso9899:199409 ISO C90 as modified in amendment 1.
| c99 ISO C99.
| gnu89 Default, ISO C90 plus GNU extensions (including some C99 features).
| gnu99
gnu9x
ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, this will become the
default. The name gnu9x is deprecated.
| c++98 The 1998 ISO C++ standard plus amendments.
| gnu++98 The same as -std=c++98 plus GNU extensions. This is the default for C++ code.
| | | | | | | | | | |
When not specified, some of the features of newer standards
if they do not conflict with previous C standards.
For example, __restrict__ when -std=c99 is not specified.
| -aux-info filename prototyped declarations for functions declared | defined,
in header file ( .h ) are output to .
The origin of each declaration, Implicit, prototyped or unprototyped :I, new(N) or old (?),
and if it was a declaration or a deFinition (C or F ).
For functions , a list of arguments and declarations. ( ed added line breaks for clarity)
ri.drivers.c/src/interfaces/rtc/ri_interface_rtc.h:46:NC */
extern uint64_t ri_rtc_millis (void);
ri.drivers.c/src/ri_driver_error.h:90:OC */
extern rd_status_t rd_errors_clear
ri.drivers.c/src/interfaces/yield/ri_interface_yield.h:53:NC */
extern rd_status_t ri_yield_init (void);
ri.drivers.c/src/ri_driver_sensor.h:599:NC */
extern _Bool rd_sensor_valid (const rd_sensor_data_t *const , const uint8_t );
Unfortunately does not include function definition not in .h or macro definitions.
or ones like app_log_process
| -fasm-blocks
Enable the use of blocks and entire functions of assembly code within a C or C++ file. The
syntax follows that used in CodeWarrior.
| -fno-asm
Do not recognize "asm", "inline" or "typeof" as a keyword,
Does recognize "__asm__", "__inline__" and "__typeof__" instead.
-ansi implies -fno-asm.
In C++, only affects typeof use the -fno-gnu-keywords instead.
C99 mode (-std=c99 or -std=gnu99), this switch only affects the "asm" and "typeof" keywords,
since "inline" is a standard keyword in ISO C99.
| -fno-builtin
-fno-builtin-function
Only recognize built-in functions that begin with__builtin_ .
With the -fno-builtin-function only the built-in function function is disabled. function
There is no corresponding -fbuiltin-function option; to
enable built-in functions selectively with -fnobuiltin or -ffreestanding ,
define macros such as:
#define abs(n) __builtin_abs ((n))
#define strcpy(d, s) __builtin_strcpy ((d), (s))
| -fhosted
Assert that compilation takes place in a hosted environment, implies -fbuiltin .
A hosted environment is where the standard library is available, and "main" has a return type of "int".
Examples are nearly everything except a kernel. This is equivalent to
| -fnofreestanding
Assert that compilation takes place in a freestanding environment. implies -fno-builtin .
A freestanding environment is where the standard library may not exist, and program start
may not be at main . An example is an OS kernel.
Equivalent to -fno-hosted .
| -fms-extensions Accept some non-standard constructs used in icrosoft headers.
-trigraphs Support ISO C trigraphs. Implied for -ansi and -std (strict ISO C conformance.)
| -no-integrated-cpp
Perform compilation in two passes: preprocessing and compiling.
Allows suppling "cc1", "cc1plus", or "cc1obj" via -B .
The supplied compilation step can add additional preprocessing steps after normal preprocessing but before compiling.
The default uses the integrated, internal cpp
| -fcond-mismatch
Allow conditional expressions with mismatched types in the second and third arguments. The value
of such an expression is void. Not for C++.
| -fno-nested-functions
Disable nested functions.
On Darwin,(Apple) nested functions are disabled by default.
not for C++ or Objective-C++.
| -fpch-preprocess Enable PCH processing with -E or -save-temps
| -fnon-lvalue-assign C and C++ forbid the use of casts and conditional expressions as lvalues,
Example:
float *p, q, r;
((int *)p)++;
(cond ? q : r) = 3.0;
Apple 4.0 allows casts and conditional expressions to be used as lvalues in certain situations.
This is accomplished via -fnon-lvalue-assign switch, which is on by default.
When an lvalue cast or an lvalue conditional expression is
encountered, the compiler issues a deprecation warning and then rewrite the expression as follows:
(type)expr ---becomes---> *(type *)&expr
cond ? expr1 : expr2 ---becomes---> *(cond ? &expr1 : &expr2)
To disallow lvalue casts and lvalue conditional expressions , specify
-fno-non-lvalue-assign ;will be disallowed in future versions of Apple's GCC.
| -funsigned-char char is unsigned, like "unsigned char".
| -fsigned-char char is signed, like "signed char".
|
-fno-signed-bitfields
-fno-unsigned-bitfields
Default, bit-fields are signed, consistant with the basic integer types such as "int" .
| -fconstant-cfstrings
Enable the automatic creation of a CoreFoundation-type constant string whenever a special builtin
"__builtin__CFStringMakeConstantString" is called on a literal string.
| -fpascal-strings
(discouraged)
Allow Pascal-style string literals.
i.e. Ⓛcccc where Ⓛ is a one byte length used with some Apple MacOS Toolbox .
For example: "\pcccc" generates x'046363636300' with a NULL terminator.
| | | | | | | | | | | | | | | | | | | | | |
|