Red Hat gcc options


GNU project C and C++ compiler

gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn] [-pedantic]
[-Idir] [-Ldir]
[-Dmacro[=defn]] [-Umacro]
[-foption] [-mmachine-option]
[-o outfile] infile

Only the most useful options are listed here; see below for the remainder. g++ accepts most of the options as gcc.
Example NeXT is omitted.

In Apple's version of GCC, both cc and gcc are links to a compiler named like gcc-version. Which compiler is linked to may be changed using gcc_select. Similarly, c++ and g++ are links to a compiler named like g++-version.
Apple's GCC includes a number of extensions to standard GCC (flagged with  , and that not all generic GCC options are available or supported on Darwin / Mac os .
NO support the compilation of Fortran, Ada, or Java.

Environment variables

When you invoke GCC, it does preprocessing, compilation, assembly and linking.
The Overall Options allow stoping at an intermediate stage. For example, -c (compile only) supress running the linker. The output consists of object files output by the assembler.

Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler. assembler and linker;
Most of these are not documented here!

Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages.

Multiple single-letter options may not be grouped.

You can mix options and other arguments.
Order does matter with options of the same kind; for example, with -L more than once, the directories are searched in the order specified.

Many options have long names starting with -f or -W ---for example, -fforce-mem, -fstrength-reduce, -Wformat and so on.
Most of these have both positive and negative forms; the negative form of -ffoo would be -fno-foo, documents the one that is not the default.

C dialect
C ++ dialect
Machine Dependent

Overall Options

-c -S -E -o file -combine -pipe -pass-exit-codes -ObjC -ObjC++  -arch arch -fsave-repository=file -x language -v -### --help --target-help --version
Language Independent
C Language Options -ansi -std=standard -aux-info filename
-faltivec -fasm-blocks  -fno-asm -fno-builtin -fno-builtin-function -fhosted -ffreestanding -fms-extensions -trigraphs -no-integrated-cpp -traditional -traditional-cpp -fallow-single-precision -fcond-mismatch -fconstant-cfstrings -fnon-lvalue-assign  -fno-nested-functions -fpch-preprocess -fsigned-bitfields -fsigned-char -fpascal-strings -wno-#warnings -wextra-tokens  -wnewline-eof -wno-altivec-long-deprecated -funsigned-bitfields -funsigned-char -fwritable-strings

C++ Language Options

-fabi-version=n -fno-access-control -fcheck-new -fconserve-space -fno-const-strings -fno-elide-constructors -fno-enforce-eh-specs -ffor-scope -fno-for-scope -fno-gnu-keywords -fno-implicit-templates -fno-implicit-inline-templates -fno-implement-inlines -fms-extensions -fno-nonansi-builtins -fno-operator-names -fno-optional-diags -fpermissive -frepo -fno-rtti -fstats -ftemplate-depth-n -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ -fno-default-inline -fvisibility-inlines-hidden -fvisibility-ms-compat
-Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel -Wno-non-template -friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo

Objective-C and Objective-C++ Language Options
-fconstant-string-class=class-name -fgnu-runtime -fno-nil-receivers -fobjc-call-cxx-cdtors -fobjc-sjlj-exceptions -fobjc-gc -freplace-objc-classes -fzero-link -gen-decls
-Wno-protocol -Wselector -Wstrict-selector-match -Wundeclared-selector

Warning Options
-fsyntax-only -pedantic -pedantic-errors -w

For All these use -Wprefix

all includes options in this color

cast-align cast-qual
import   no-import










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
-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=$( 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

Options Controlling the Kind of Output

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.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.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.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.for, file.FORFortran should not be preprocessed.
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
                   f77  f77-cpp-input  ratfor

-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++ 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:
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++.
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).
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.

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".
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.

Controlling C++ Dialect

Only for C++ programs;
Can use most of the GNU compiler options regardless of the language .
For example, to compile a file "firstClass.C" :
g++ -g -frepo -O -c firstClass.C
-frepo is for C++ programs;
-fabi-version=n Use version n of the C++ ABI. Version 2 is the version of the C++ ABI that first appeared in G++ 3.4. Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. Version 0 will always be the version that conforms most closely to the C++ ABI specification. Therefore, the ABI obtained using version 0 will change as ABI bugs are fixed. The default is version 2.
-fno-access-control Turn off all access checking. useful for working around bugs in the access control code.
-fcheck-new Check that the pointer returned by "operator new" is non-null before attempting to modify the storage allocated. This check is normally unnecessary because the C++ standard specifies that "operator new" will only return 0 if it is declared throw(), in which case the compiler will always check the return value even without this option. In all other cases, when "operator new" has a non-empty exception specification, memory exhaustion is signalled by throwing "std::bad_alloc". See also new (nothrow).
-fconserve-space Put uninitialized or runtime-initialized global variables into the common segment, as C does. This saves space in the executable at the cost of not diagnosing duplicate definitions. If you compile with this flag and your program mysteriously crashes after "main()" has completed, you may have an object that is being destroyed twice because two definitions were merged. is no longer useful on most targets, now that support has been added for putting variables into BSS without making them common.
-fno-const-strings Give string constants type "char *" instead of type "const char *". By default, G++ uses type "const char *" as required by the standard. Even if you use -fno-const-strings, you cannot actually modify the value of a string constant, unless you also use -fwritable-strings. might be removed in a future release of G++. For maximum portability, you should structure your code so that it works with string constants that have type "const char *".
-fno-elide-constructors The C++ standard allows an implementation to omit creating a temporary which is only used to initialize another object of the same type. Specifying this option disables that optimization, and forces G++ to call the copy constructor in all cases.
-fno-enforce-eh-specs Don't check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining NDEBUG. The compiler will still optimize based on the exception specifications.
-fno-for-scope scope of variables declared in a for-init-statement is limited to the loop ,
With no-for-scope they extend to the end of the enclosing scope, Default: follow the standard, give warning for code that would otherwise be invalid, or have different behavior.
-fno-gnu-keywords Do not recognize typeof as a keyword, this which can then be used as an identifier.
__typeof__ is still valid. -ansi implies no-gnu-keywords.
-frepo Enable automatic template instantiation at link time. Implies no-implicit-templates.
-fno-implicit-templates non-inline templates which are instantiated implicitly (i.e. by use.) do not generate code.
-fno-implicit-inline-templates In addition to implicit non-inline templets, Don't emit code for implicit instantiations of inline templates.
The default : handle inlines differently so that compiles with and without optimization will need the same set of explicit instantiations.
-fno-implement-inlines Do not emit out-of-line copies of inline functions controlled by #pragma implementation.
Results in linker errors if these functions are not inlined everywhere they are called.
-fms-extensions Disable warnings about constructs used in MFC, such as implicit int and getting a pointer to member function via non-standard syntax.
-fno-nonansi-builtins Disable built-in declarations of functions that are not mandated by ANSI/ISO C. including ffs, alloca, _exit, index, bzero, conjf and related functions.
-fno-operator-names Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords.
-fno-optional-diags Disable diagnostics that the standard does not require.
Only one is for a name having multiple meanings within a class.
-fpermissive Downgrade some diagnostics about nonconformant code from errors to warnings.
-fno-rtti Disable generation of information about every class with virtual functions for use by the C++ runtime type identification features (dynamic_cast and typeid). Exception handling still generates this information.
-ftemplate-depth-n Maximum instantiation depth for template classes to detect endless recursions
-fno-threadsafe-statics Do not emit the extra code to use the routines specified in the C++ ABI for thread-safe initialization of local statics.
-fuse-cxa-atexit Register destructors for objects with static storage duration with the "__cxa_atexit" function rather than the "atexit" function. Required for fully standards-compliant handling of static destructors.
-fno-use-cxa-get-exception-ptr Don't use the "__cxa_get_exception_ptr" runtime routine. Causes "std::uncaught_exception" to be incorrect, but is necessary if the runtime routine is not available.
-fvisibility-inlines-hidden Declares that no attempt to compare pointers to inline methods where the addresses of the two functions were taken in different shared objects.

Mark inline methods with __attribute__ ((visibility ("hidden"))) so that they do not appear in the export table of a DSO and do not require a PLT indirection when used within the DSO.
Not the same as marking the methods as hidden directly. Normally if there is a class with default visibility which has a hidden method, the effect of this is that the method must be defined in only one shared object. This switch does not have this restriction. mark a method as having a visibility explicitly to negate the effect of the switch for that method. For example, to compare pointers to a particular inline method, mark it as having default visibility.

-fvisibility-ms-compat Use visibility settings to make linkage model compatible with Microsoft Visual Studio.

  1. sets default visibility to hidden, like -fvisibility=hidden.
  2. . Types, but not their members, are not hidden by default.
  3. . The One Definition Rule is relaxed for types without explicit visibility specifications which are defined in more than one different shared object: those declarations are permitted if they would have been permitted when this option was not used.
Is discouraged, preferable for types to be explicitly exported as desired on a per-class basis. because Visual Studio can't compare two different hidden types as unequal for the purposes of type_info and exception handling, users are able to write code that relies upon this behavior.

consequences are that static data members of the same type with the same name but defined in different shared objects will be different, so changing one will not change the other; and that pointers to function members defined in different shared objects will not compare equal.
It is a violation of the ODR to define types with the same name differently.

-fno-default-inline Do not assume inline for functions defined inside a class scope. these functions will have linkage like inline functions; they won't be inlined by default.
(C++ only)
Warn when code is not compatible with the vendor-neutral C++ ABI. Include:
  • Incorrect handling of tail-padding for bit-fields.
  • Incorrect handling of tail-padding for virtual bases. G++ does not use tail padding when
  • Incorrect handling of bit-fields with declared widths greater than that of their underlying types, when the bit-fields appear in a union.
  • Empty classes can be placed at incorrect offsets.
  • Names of template functions whose types involve "typename" or template template parameters can be mangled incorrectly.
  • i-Wctor-dtor-privacy
    (C++ only)
    Warn when a class seems unusable because all the constructors or destructors in that class are private, and it has neither friends nor public static member functions.
    (C++ only)
    Warn when a class appears to be polymorphic, thereby requiring a virtual destructor, yet it declares a non-virtual one.
    Enabled by all.
    (C++ only)
    Warn when the order of member initializers given in the code does not match the order in which they must be executed.
    Not affected by all.
    (C++ only)
    Warn about violations of the following style guidelines from Scott Meyers' Effective C++ book:
  • Item 6: Distinguish between prefix and postfix forms of increment and decrement operators.
  • Item 7: Never overload && , || i, or ,.
  • Item 11: Define a copy constructor and an assignment operator for classes with dynamically allocated memory.
  • Item 12: Prefer initialization to assignment in constructors.
  • Item 14: Make destructors virtual in base classes.
  • Item 15: Have "operator=" return a reference to *this.
  • Item 23: Don't try to return a reference when you must return an object.
  • Incorrect handling of bit-fields with declared widths greater than that of their underlying types, when the bit-fields appear in a union.
  • Empty classes can be placed at incorrect offsets.
  • Names of template functions whose types involve "typename" or template template parameters can be mangled incorrectly.
  • -nostdinc++ Do not search for header files in the standard directories specific to C++, search the other standard directories. used when building the C++ library.
    (C++ only)
    Warn when a class seems unusable because all the constructors or destructors in that class are private, and it has neither friends nor public static member functions.
    (C++ only)
    Do not warn about deprecated features.
    (C++ only)
    uncasted "NULL" as sentinel.
    (C++ only)
    Disable warnings when non-templatized friend functions are declared within a template.
    (C++ only)
    an old-style (C-style) cast to a non-void type is used
    (C++ only)
    function declaration hides virtual functions from a base class.
    (C++ only)
    Disable the diagnostic for converting a bound pointer to member function to a plain pointer.
    (C++ only)
    overload resolution chooses a promotion from unsigned or enumerated type to a signed type, over a conversion to an unsigned type of the same size.

    Options Controlling Objective-C and Objective-C++ Dialects

                   gcc -g -fgnu-runtime -O -c some_class.m
    Objective-C is an extension of the C language, Objective-C compilations may also use options specific to the C front-end (e.g., -Wtraditional). Similarly, Objective-C++ compilations may use C++-specific options (e.g., -Wabi). options only for compiling Objective-C and Objective-C++ programs:
    -fconstant-string-class=class-name Use class-name as the name of the class to instantiate for each literal string specified with the syntax "@"..."". The default class name is "NXConstantString" if the GNU runtime is being used, and "NSConstantString" The -fconstant-cfstrings overrides -fconstant-string-class and cause "@"..."" literals to be laid out as constant CoreFoundation strings.
    -fgnu-runtime Generate object code compatible with the standard GNU Objective-C runtime. default for most types of systems.
    -gen-decls Dump interface declarations for all classes seen in the source file to a file named sourcename.decl.
    -Wno-protocol If a class is declared to implement a protocol, a warning is issued for every method in the protocol that is not implemented by the class. The default behavior is to issue a warning for every method not explicitly implemented in the class, even if a method implementation is inherited from the superclass. If you use the -Wno-protocol option, then methods inherited from the superclass are considered to be implemented, and no warning is issued for them.
    -Wselector Warn if multiple methods of different types for the same selector are found during compilation. The check is performed on the list of methods in the final stage of compilation. Additionally, a check is performed for each selector appearing in a "@selector(...)" expression, and a corresponding method for that selector has been found during compilation. Because these checks scan the method table only at the end of compilation, these warnings are not produced if the final stage of compilation is not reached, for example because an error is found during compilation, or because the -fsyntax-only option is being used.
    -Wstrict-selector-match Warn if multiple methods with differing argument and/or return types are found for a given selector when attempting to send a message using this selector to a receiver of type "id" or "Class". When this flag is off (which is the default behavior), the compiler will omit such warnings if any differences found are confined to types which share the same size and alignment.
    -Wundeclared-selector Warn if a "@selector(...)" expression referring to an undeclared selector is found. A selector is considered undeclared if no method with that name has been declared before the "@selector(...)" expression, either explicitly in an @interface or @protocol declaration, or implicitly in an @implementation section. This option always performs its checks as soon as a "@selector(...)" expression is found, while -Wselector only performs its checks in the final stage of compilation. This also enforces the coding style convention that methods and selectors must be declared before being used.
    -print-objc-runtime-info Generate C header describing the largest structure that is passed by value, if any.

    Control Diagnostic Messages Formatting

    formatting algorithm, e.g. how many characters per line, how often source location information should be reported.
    -fmessage-length=n Format error messages so that they fit on lines of about n characters. default 72 characters for g++ and 0 for the rest of the front ends supported by GCC.
    If n is zero, no line-wrapping will be done; each error message will appear on a single line.
    -fdiagnostics-show-location=once Only meaningful in line-wrapping mode. Emit once source location information; that is, in case the message is too long to fit on a single physical line and has to be wrapped, the source location won't be emitted (as prefix) again, over and over, in subsequent continuation lines. default behavior.
    -fdiagnostics-show-location=every-line Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit the same source location information (as prefix) for physical lines that result from the process of breaking a message which is too long to fit on a single line.

    Include or Suppress Warnings

    Warnings report constructions which are not inherently erroneous but which are risky or suggest there may have been an error.

    You can request many specific warnings with options beginning -W, for example -Wimplicit to request warnings on implicit declarations. these warning options have a negative form beginning -Wno- to turn off warnings; for example, -Wno-implicit. Here is liskted only the not the default form.

    Otions rendered like this are included in -Wall.

    -fsyntax-only Check the code for syntax errors only.
    -pedantic Issue all the warnings demanded by strict ISO C and ISO C++;

    -pedantic-errors Like -pedantic, except that errors are produced rather than warnings.
    -w Inhibit all warning messages.
    -Wno-import Inhibit warning messages about the use of #import.
    -Wno-#warnings Inhibit messages issued by #warning.
    -Wextra-tokens extra tokens at the end of prepreprocessor directives. 
    -Wnewline-eof files missing a newline at the end of the file. 
    -Wno-altivec-long-deprecated Do not warn about the use of the deprecated long keyword in AltiVec data types. 
    -Wchar-subscripts Warn if an array subscript has type "char".
    enabled by -Wall.
    -Wcomment Warn if there's a comment within a comment,
    i.e. when a /* is in a /* comment or
    when a Backslash-Newline appears in a // comment.
    Enabled by -Wall.
    -Wfatal-errors abort compilation on the first error / warning
    -Wformat Check arguments to printf and scanf, etc., for types appropriate to the format string, and conversions make sense.
    This includes standard functions, and others specified by format attributes, in the "printf", "scanf", "strftime" and "strfmon"
    Functions checks depends on the standard version selected,
    Disabled with -ffreestanding or -fno-builtin.

    Checks for null format arguments for several functions, implies -Wnonnull.

    Included in -Wall.
    For more control over some aspects of format checking, the options -Wformat-y2k, -Wno-format-extra-args, -Wno-format-zero-length, -Wformat-nonliteral, -Wformat-security, and -Wformat=2 not included in -Wall.

    -Wformat-y2k If -Wformat is specified, also warn about "strftime" formats which may yield only a two-digit year.
    -Wno-format-extra-args If -Wformat is specified, do not warn about excess arguments to a "printf" or "scanf" format function. The C standard specifies that such arguments are ignored.
    Where the unused arguments lie between used arguments that are specified with $ operand number specifications, normally warnings are still given, since the implementation could not know what type to pass to "va_arg" to skip the unused arguments.
    In the case of "scanf" formats, suppresses the warning if the unused arguments are all pointers>
    -Wno-format-zero-length If -Wformat is specified, do not warn about zero-length formats.
    -Wformat-nonliteral If -Wformat is specified, also warn if the format string is not a string literal and so cannot be checked, unless the format function takes its format arguments as a "va_list".
    -Wformat-security format calls with security problems. i.e. the format string is not a literal and there are no format arguments.
    A subset of -Wformat-nonliteral
    -Wformat=2 equivalent to format, -nonliteral, -security, -y2k.
    -Wnonnull passing a null pointer for arguments marked as requiring a non-null
    Included in all and format.
    (C, C++, Objective-C and Objective-C++ only)
    Uninitialized variables which are initialized with themselves.
    Only with uninitialized and -O1.
    example: int i = i;
    -Wimplicit-int Declaration does not specify a type.
    enabled by all.
    a function is used before being declared. The form -Wno-error-implicit-function-declaration is not supported.
    enabled by all as a warning.
    -Wimplicit implicit-int and implicit-function-declaration.
    enabled by all.
    -Wmain Main is not a function with external linkage, returning int, zero, two, or three arguments of appropriate types.
    Enabled by all.
    -Wmissing-braces aggregate or union initializer is not fully bracketed.
      int bad [2][2] = { 0, 1, 2, 3 };   /* not fully bracketed */
      int good[2][2] = { { 0, 1 }, { 2, 3 } };/* fully bracketed. */
    Enabled by all.
    -Wmissing-include-dirs user-supplied include directory does not exist.
    -Wparentheses Parentheses are omitted in certain contexts, such as:
  • there is an assignment where a truth value is expected c++ only, or
  • operators are nested whose precedence is confusing .
  • comparison of the form x<=y<=z is not the same as mathematical notation.
  • Unclear if association with else branch belongs.
             if (a)
              if (b)
                 foo ();
                 bar (); 
    To eliminate the warning, add explicit braces around the innermost if statement so there is no way the else could belong to the enclosing if. Enabled by all.
  • -Wsequence-point code that may have undefined semantics because of violations of sequence point rules. gnu Warnings Enabled by all.
    -Wreturn-type Warn whenever a function is defined with a return-type that defaults to "int". Also warn about any "return" statement with no return-value in a function whose return-type is not "void". For C, also warn if the return type of a function has a type qualifier such as "const". Such a type qualifier has no effect, since the value returned by a function is not an lvalue. ISO C prohibits qualified "void" return types on function definitions, so such return types always receive a warning even without this option. For C++, a function without return type always produces a diagnostic message, even when -Wno-return-type is specified. The only exceptions are main and functions defined in system headers. enabled by all.
    -Wswitch Warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that enumeration. (The presence of a "default" label prevents this warning.) "case" labels outside the enumeration range also provoke warnings when this option is used.
    enabled by all.
    -Wswitch-default Warn whenever a "switch" statement does not have a "default" case.
    -Wswitch-enum Warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that enumeration. "case" labels outside the enumeration range also provoke warnings when this option is used.
    -Wtrigraphs Warn if any trigraphs are encountered that might change the meaning of the program (trigraphs within comments are not warned about).
    enabled by all.
    -Wunused-function Warn when a static function is declared but not defined or a non\-inline static function is unused. enabled by all
    -Wunused-label Warn whenever a label is declared but not used. enabled by all.
    To suppress this warning use the unused attribute.
    -Wunused-parameter Warn whenever a function parameter is unused aside from its declaration.
    To suppress this warning use the unused attribute.
    -Wunused-variable Warn whenever a local variable or non-constant static variable is unused aside from its declaration
    enabled by all.
    To suppress this warning use the unused attribute.
    -Wunused-value Warn whenever a statement computes a result that is explicitly not used.
    enabled by all.
    To suppress this warning cast the expression to void.
    -Wunused All the above -Wunused options combined. In order to get a warning about an unused function parameter, either specify -Wextra -Wunused (note that -Wall implies -Wunused), or separately specify -Wunused-parameter.
    -Wuninitialized Warn if an automatic variable is used without first being initialized or if a variable may be clobbered by a "setjmp" call.
    to warn about code which uses the uninitialized value of the variable in its own initializer, use the -Winit-self .
    These warnings occur for individual uninitialized or clobbered elements of structure, union or array variables as well as for variables which are uninitialized or clobbered as a whole. They do not occur for variables or elements declared "volatile". Because these warnings depend on optimization, the exact variables or elements for which there are warnings will depend on the precise optimization options and version of GCC used.
    Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed.
    This warning is enabled by -Wall.
    -Wunknown-pragmas Warn when a #pragma directive is encountered which is not understood by GCC. If this command line option is used, warnings will even be issued for unknown pragmas in system header files. This is not the case if the warnings were only enabled by the -Wall command line option.
    -Wstrict-aliasing is only active when -fstrict-aliasing is active. It warns about code which might break the strict aliasing rules that the compiler is using for optimization. The warning does not catch all cases, but does attempt to catch the more common pitfalls. It is included in -Wall.
    -Wstrict-aliasing=2 is only active when -fstrict-aliasing is active. It warns about all code which might break the strict aliasing rules that the compiler is using for optimization. This warning catches all cases, but it will also give a warning for some ambiguous cases that are safe.
    -Wall All of the above -W options combined
    -Wmost equivalent to -Wall -Wno-parentheses. 

    These -W&ellip; options are not implied by -Wall.
    Output extra warnings for:
    • WIth -Wall or -Wunused warn about unused arguments.
    • A function can return either with or without a value. For example,
       foo (a)
                               if (a > 0) return a;
                              implied return  /* with no value */
    • An expression-statement or the left-hand side of a comma expression contains no side effects. For example, x[i,j]. The maybe some other issue.
    • An unsigned value being compared to zero with < or = since an unsigned cannot be negative!
    • Storage-class specifiers like static are not the first in a declaration.
    • A comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned.
      Not with -Wno-sign-compare
    • An aggregate has an initializer which does ?not initialize all members.
      see -Wmissing-field-initializers.
    • A function parameter is declared without a type specifier in K&R-style functions:
      void foo(bar) { }
    • An empty body in an if or else
    • A pointer is compared against integer zero with <, <=, >, or >=.
    • A variable might be changed by longjmp or vfork.
    • floating-point events that indicate errors, such as overflow, underflow, loss of precision, etc.
      C++ only
    • An enumerator and a non-enumerator both appear in a conditional expression.
    • A non-static reference or non-static const member appears in a class without constructors.
    • Ambiguous virtual bases.
    • Subscripting an array which has been declared register.
    • Taking the address of a variable which has been declared register.
    • A base class is not initialized in a derived class' copy constructor.
    -Wno-div-by-zero Do not warn about compile-time integer division by zero.
    Floating point division by zero is not warned.
    -Wsystem-headers Output warnings for constructs in system header files which are normally suppressed.
    emit warnings from system headers as if in user code.
    Using -Wall in conjunction with this option will not warn about unknown pragmas in system headers---for that, -Wunknown-pragmas must also be used.
    -Wfloat-equalfloating point values are used in equality comparisons.
    (C only)
    constructs that behave differently in traditional and ISO C and ISO C constructs that have no traditional C equivalent, and/or problematic constructs which should be avoided.
  • Macro parameters that appear within string literals in the macro body. In traditional C macro replacement takes place within string literals, but does not in ISO C.
  • Some preprocessor directives do not exist.
    < Traditional preprocessors only consider a line a directive if the # is in column 1 .
    -Wtraditional warns about directives that traditional C understands but would ignore because the # does not appear as the first character on the line.
    Hide directives like #pragma not understood by traditional C by indenting them.
    Some traditional implementations would not recognize #elif.
  • A function-like macro that appears without arguments.
  • The unary plus operator.
  • The U integer constant suffix, or the F or L floating point constant suffixes.
    Traditional C does support the L suffix on integer constants.)
    these suffixes appear in macros defined in the system headers of systems, example _MIN/_MAX macros in . these macros might lead to spurious warnings,
  • A function declared external in one block and then used after the end of the block.
  • switch with a long operand
  • A non-static function declaration follows a static one.
  • The ISO type of an integer constant has a different width or signedness from its traditional type if the base of the constant is ten.
    I.e. hexadecimal or octal values, which typically represent bit patterns, are not warned about.
  • Usage of ISO string concatenation
  • Initialization of automatic aggregates.
  • Identifier conflicts with labels.
  • Initialization of unions.
    If the initializer is zero, the warning is omitted.
    This is done under the assumption that the zero initializer appears conditioned on e.g. "__STDC__" to avoid missing initializer warnings and relies on default initialization to zero in the traditional C case.
  • Conversions by prototypes between fixed/floating point values and vice versa.
    This is a subset of the conversion warnings, for the full set use -Wconversion.
  • Use of ISO C style function definitions.
    not issued for prototype declarations or variadic functions because these ISO C features will appear in your code when using libiberty's traditional C compatibility macros, "PARAMS" and "VPARAMS". This warning is also bypassed for nested functions because that feature is already a GCC extension and thus not relevant to traditional C compatibility.
  • -Wdeclaration-after-statement (C only) Warn when a declaration is found after a statement in a block. This construct, known from C++, was introduced with ISO C99 and is by default allowed in GCC. It is not supported by ISO C90 and was not supported by GCC versions before GCC 3.0.
    -Wno-discard-qual This flag allows user to suppress warning that is issued when qualification is discarded in situations like, initialization, assignment and argument passing.
    -Wundef Warn if an undefined identifier is evaluated in an #if directive.
    -Wno-endif-labels Do not warn whenever an #else or an #endif are followed by text.
    -Wshadow Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed.
    -Wlarger-than-len Warn whenever an object of larger than len bytes is defined.
    -Wpointer-arith Warn about anything that depends on the size of a function type or of "void".
    These types a size ssigned 1, for convenience in calculations with "void *" pointers and pointers to functions.
    -Wbad-function-cast (C only) Warn whenever a function call is cast to a non-matching type. For example, warn if "int malloc()" is cast to "anything *".
    -Wcast-qual Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example, warn if a "const char *" is cast to an ordinary "char *".
    -Wcast-align Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.
    -Wwrite-strings When compiling C, give string constants the type "const char[length]" so that copying the address of one into a non-"const" "char *" pointer will get a warning; when compiling C++, warn about the deprecated conversion from string constants to "char *". These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using "const" in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make -Wall request these warnings.
    -Wconversion Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signedness of a fixed point argument except when the same as the default promotion. Also, warn if a negative integer constant expression is implicitly converted to an unsigned type. For example, warn about the assignment "x = -1" if "x" is unsigned. But do not warn about explicit casts like "(unsigned) -1".
    -Wshorten-64-to-32 Warn if a value is implicitly converted from a 64 bit type to a 32 bit type.
    -Wsign-compare Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. This warning is also enabled by -Wextra; to get the other warnings of -Wextra without this warning, use -Wextra -Wno-sign-compare.
    -Waggregate-return Warn if any functions that return structures or unions are defined or called. (In languages where you can return an array, this also elicits a warning.)
    (C only)
    Warn if a function is declared or defined without specifying the argument types.
    (C only)
    Warn if an old-style function definition is used, even if there is a previous prototype.
    (C only)
    Warn if a global function is defined without a previous prototype declaration, even if the definition provides a prototype.
    Global functions should be declared in a header file.
    (C only)
    Warn if a global function is defined without a previous declaration, even if the definition provides a prototype.
    Detects global functions that are not declared in header files.
    -Wmissing-field-initializers Warn if a structure's initializer has fields missing.
    For example, "x.h" is implicitly zero:
                       struct s { int f, g, h; };
                       struct s x = { 3, 4 };
    Does NOT warn about designated initializers
                       struct s { int f, g, h; };
                       struct s x = { .f = 3, .g = 4 };
    Included in -Wextra.
    To get -W warnings without this , use -Wextra -Wno-missing-field-initializers.
    -Wmissing-noreturn Warn about functions which might be candidates for attribute "noreturn".
    -Wmissing-format-attribute With -Wformat or -Wall warn about functions which might be candidates for "format" attributes like functions that call "vprintf" or "vscanf"
    -Wno-multichar Do not warn if a multicharacter constant ('FOO') is used. Perhaps they are meant to be a string ("FOO")

    Does not warn for a constant with four characters, use -Wfour-char-constants

    -Wfour-char-constants Warn about four char constants, e.g. OSType 'APPL'. Disabled by default. It is not an error to use several characters as a character constant (although it can be argured that it should be) .
    -Wnormalized=|id|nfc|nfkc> Identifiers can have two different character sequences and look the same if they are not ASCII!

    The default is -Wnormalized=nfc , which warns about any identifier which is not in the ISO 10646 C normalized form.

    -Wno-deprecated-declarations Do not warn about uses of functions, variables, and types marked as deprecated by using the deprecated attribute.
    -Wpacked Warn if a structure is given the packed attribute, but no effect on the layout or size of the structure.
    For examplex the variable "f.x" in "struct bar" will be misaligned even though "struct bar" does not have the packed attribute:
                       struct foo {
                         int x;
                         char a, b, c, d;
                       } __attribute__((packed));
                       struct bar {
                         char z;
                         struct foo f;
    -Wpadded Warn if padding is added in a structure, to align an element of the structure or to align the whole structure.
    -Wredundant-decls Warn if anything is declared more than once in the same scope
    -Wnested-externs (C only) Warn if extern is encountered within a function.
    -Wunreachable-code Warn if code will never be executed.
    However, when a function is inlined, a warning may mean that the line is unreachable in only one inlined copy of the function.

    Not included in -Wall

    Unreachable code may be to provide behavior which is selectable at compile-time.

    -Winline Warn if a function can not be inlined and it was declared as inline.
    Will not warn about failures to inline functions declared in system headers.
    (C++ only)
    Suppress warnings from applying the offsetof macro to a non-POD type. According to the 1998 ISO C++ standard, applying offsetof to a non-POD type is undefined. In existing C++ implementations, however, offsetof typically gives meaningful results even when applied to certain kinds of non- POD types. (Such as a simple struct that fails to be a POD type only by virtue of having a constructor.) This flag is for users who are aware that they are writing nonportable code and who have deliberately chosen to ignore the warning about it. The restrictions on offsetof may be relaxed in a future version of the C++ standard.
    (C only)
    Suppress warnings from casts to pointer type of an integer of a different size.
    (C only)
    Suppress warnings from casts from a pointer to an integer type of a different size.
    -Winvalid-pch Warn if a precompiled header is found in the search path but can't be used.
    -Wlong-long Warn if long long type is used. This is default. To inhibit the warning messages, use -Wno-long-long.
    -Wlong-long and -Wno-long-long are taken into account only with -pedantic
    -Wvariadic-macros Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU alternate syntax when in pedantic ISO C99 mode. This is default. To inhibit the warning messages, use -Wno-variadic-macros.
    -Wdisabled-optimization Warn if a requested optimization pass is disabled. This warning does not generally indicate that there is anything wrong with your code; it merely indicates that GCC's optimizers were unable to handle the code effectively. Often, the problem is that your code is too big or too complex; GCC will refuse to optimize programs when the optimization itself is likely to take inordinate amounts of time.
    -Wno-pointer-sign Don't warn for pointer argument passing or assignment with different signedness. Only useful in the negative form since this warning is enabled by default. This option is only supported for C and Objective-C.
    -Wstack-protector WIth -fstack-protector warns about functions that will not be protected against stack smashing.
    -Werror Treat warnings as errors.

    Options for Debugging

    See gnu debugging

    -g Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). For GDB.
    Using -g with -O complicates debugging.
    -ggdb Produce debugging information for use by GDB.
    -flimit-debug-info Limit debug information produced to reduce size of debug binary.
    -feliminate-unused-debug-symbols Produce debugging information in stabs format for only symbols used.
    -gstabs+ Produce debugging information in stabs format using GNU extensions
    debugging level.
    Default 2.
    Level 0 none.
    Level 1 minimal information, enough for making backtraces. Includes descriptions of functions and external variables, but no information about local variables and no line numbers.
    Level 3 includes the macro definitions present in the program. May include macro expansion
    -p Generate output for analysis program prof.
    -Q output each function name as it is compiled, and statistics about each pass when it finishes.
    -ftime-report output statistics about the time consumed by each pass when it finishes.
    -fmem-report output statistics about permanent memory allocation when it finishes.
    -dD Dump macro definitions, at the end of preprocessing, in addition to normal output.
    # 1 "../../../main.c"
    # 1 "/Volumes/DATA/dgerman/Documents/computerstuff/phyweb/ruuvi/firmware/3.31.1/304/src/targets/ruuvitag_b/armgcc//"
    # 1 "<built-in>"
    #define __STDC__ 1
    # 1 "<command-line>"
    #define __USES_INITFINI__ 1
    #define RUUVI_RUN_TESTS 1
    #define DEBUG 1
    #define APP_FW_VERSION "v3.31.1"
    #define __HEAP_SIZE 64
    #define __STACK_SIZE 8192
    # 1 "../../../main.c"
    # 12 "../../../main.c"      first include at line 12
    # 1 "../../../application_config/app_config.h" 1
    # 22 "../../../application_config/app_config.h"
    Here's the rest 5,961 lines just for main.c

    main.c.d Here's the includes

    Produce all dumps .
    -dm Output statistics on memory usage, at the end of the run, to standard error.
    -save-temps Store the temporary intermediate files in the current directory and name them based on the source file. compiling foo.c with -c -save-temps would produce files foo.i and foo.s, as well as foo.o.
    This creates a preprocessed foo.i output file.
    With -x
    -time Report the CPU time taken by each subprocess
    -print-file-name=library ONLY Output the full absolute name of the file library for linking.
    -print-multi-directory Print the directory name corresponding to the multilib selected by any other switches present in the command line. This directory id in in GCC_EXEC_PREFIX.
    -print-multi-lib Print the mapping from multilib directory names to compiler switches that enable them. The directory name is separated from the switches by ;, and each switch starts with an @} instead of the @samp{-, without spaces between multiple switches to ease shell- processing.
    -print-prog-name=program Like -print-file-name, but searches for a program such as cpp.
    -print-libgcc-file-name Same as -print-file-name=libgcc.a.
    > gcc  -print-libgcc-file-name     
    This is useful when you use -nostdlib or -nodefaultlibs but you do want to link with libgcc.a. You can do gcc -nostdlib ... `gcc -print-libgcc-file-name`
    -print-search-dirs ONLY output the name of the installation directory and a list of program and library directories gcc will search
     > gcc  -print-search-dirs
    programs: =/Library/Developer/CommandLineTools/usr/bin
    libraries: =/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0
    -dumpmachine ONLY output the compiler's target machine (for example, i686-pc-linux-gnu)
    -dumpspecs Print the compiler's built-in specs


    Most optimizations are to complicated to be used by most developers and their desctiptions are not included here.
    If you must, see

    Optimization levels

    -O0 Do not optimize. This is the default.
    reduce code size and execution time,

    does not interfere with debugging.

    -O2 and above, enable unit-at-a-time mode, which has the compiler consider information gained from later functions in the file when compiling a function.
    Compiling multiple files at once to a single output file allows the compiler to use information gained from all of the files
    -O2 In addition to flags for -O,
    Performs most optimizations not involving a space-speed tradeoff.
    Does not perform loop unrolling or function inlining

    In Apple's version , -fstrict-aliasing, -freorder-blocks, and -fsched-interblock
    are disabled by default when optimizing.

    -O3 all optimizations specified by -O2 and -finline-functions, -funswitch-loops and -fgcse-after-reload options.
    -Os Optimize for size, but not at the expense of speed. -O2 optimizations that do not typically increase code size. Instructions are chosen for best performance, regardless of size.
    To optimize solely for size on Darwin, use -Oz . The following options are set for -O2, are disabled under -Os: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays

    When optimizing with -Os or -Oz on Darwin, any function up to 30 estimated insns will be considered for inlining.
    When compiling C and Objective-C sourcefiles with -Os or -Oz on Darwin, functions explictly marked with the "inline" keyword up to 450 estimated insns in size will be considered for inlining.

    -Oz  Optimize for size, regardless of performance. optimization flags as -Os uses, also enables other optimizations intended solely to reduce code size.
    Instructions that encode into fewer bytes are preferred over longer instructions that execute in fewer cycles.
    On Darwin is very similar to -Os in FSF distributions of GCC.
    Employs the same inlining limits and avoids string instructions as -Os.

    Options Controlling the Preprocessor

    -E only preprocess
    -D name Predefine name as a macro, with definition 1.
    -D name=definition Definition is tokenized and processed as if were a #define directive, Definition will be truncated by embedded newlines <
    When invoking the preprocessor from a shell use shell's quoting to protect characters such as spaces that have a meaning in the shell syntax.

    To define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals sign . Use quotes to supress shell function .
    For example with sh and csh, -D'name(args...)=definition'

    -U name Undefine name, either built in or provided with a -D option. -D and -U are processed in the order they are given .
    All -imacros file and -include file are processed after -D and -U
    -undef Do not predefine any system-specific macros. The standard predefined macros remain defined.
    -I dir Add the directory dir to the list of directories to be searched for includes . searched before the standard system include directories.
    If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system headers are not defeated .
    -o file Write output to file. as specifying file as the second non-option argument to cpp.
    -Wall Turns on all optional warnings which are desirable for normal code. comment, trigraphs, multichar and a warning about integer promotion causing a change of
    -Wcomment[s] a comment-start (/* appears within a /* , or
    a backslash- newline appears in a // comment.(i.e. a line ends in a \)
    -Wtraditional Warn about certain constructs that behave differently in traditional and ISO C. Also warn about ISO C constructs that have no traditional C equivalent, and problematic constructs which should be avoided.
    -Wimport Warn the first time #import is used.
    -Wundef Warn whenever an identifier which is not a macro is encountered in an #if directive, outside of defined. Such identifiers are replaced with zero.
    -Wunused-macros Warn about macros defined in the main file that are unused. A macro is used if it is expanded or tested for existence at least once. The preprocessor will also warn if the macro has not been used at the time it is redefined or undefined. Built-in macros, macros defined on the command line, and macros defined in include files are not warned about. If a macro is actually used, but only used in skipped conditional blocks, then CPP will report it as unused. To avoid the warning in such a case, you might improve the scope of the macro's definition by, for example, moving it into the first skipped block. Alternatively, you could provide a dummy use with something like: #if defined the_macro_causing_the_warning #endif
    -Wendif-labels Warn whenever an #else or an #endif are followed by text. This usually happens in code of the form
                       #if FOO
                       #else FOO
                       #endif FOO
    The second and third "FOO" should be in comments
    on by default.
    -Werror Make all warnings into hard errors. Source code which triggers warnings will be rejected.
    -Wsystem-headers Issue warnings for code in system headers.
    -W Suppress all warnings,
    -pedantic Issue mandatory diagnostics listed in the C standard. Some are left out by default,
    -pedantic-errors make mandatory diagnostics into errors.

    Make related options

    -M output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

    Unless specified explicitly (with -MT or -MQ), the object file name consists of the basename of the source file with any suffix replaced with object file suffix. If there are many included files then the rule is split into several lines using \-newline. The rule has no commands.

    does not suppress the preprocessor's debug output, such as -dM. To avoid mixing such debug output with the dependency rules explicitly specify the dependency output file with -MF, or use an environment variable like DEPENDENCIES_OUTPUT. Debug output will still be sent to the regular output stream

    -M implies -E, and suppresses warnings with an implicit -w.

    -MM Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.

    This implies that the choice of angle brackets or double quotes in an #include directive does not in itself determine whether that header will appear in -MM dependency output. @anchor{dashMF}

    -MF file with -M or -MM, a file to write the dependencies to. If no -MF switch is given the preprocessor sends the rules to the same place it would have sent preprocessed output. When used with the driver options -MD or -MMD, -MF overrides the default dependency output file.
    -dependency-file Like -MF. 
    -MG with an option such as , -MG assumes missing header files are generated files and adds them to the dependency list without raising an error. The dependency filename is taken directly from the "#include" directive without prepending any path. -MG also suppresses preprocessed output, as a missing header file renders this useless. This feature is used in automatic updating of makefiles.
    -MP add a phony target for each dependency other than the main file, causing each to depend on nothing. to work around errors make gives if header files are removed without updating the Makefile to match. Example:
                       test.o: test.c test.h
    -MT target Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, including any path, deletes any file suffix such as .c, and appends the platform's usual object suffix. The result is the target. An -MT option will set the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to -MT, or use multiple -MT options.
    For example, -MT '$(objpfx)foo.o' might give
                       $(objpfx)foo.o: foo.c
    -MQ target Same as -MT, but it quotes any characters which are special to Make.
    -MQ '$(objpfx)foo.o' gives
                       $$(objpfx)foo.o: foo.c
    The default target is automatically quoted, as if it were given with -MQ.
    -MD -MD is equivalent to -M -MF file, except that -E is not implied. The driver determines file based on whether an -o option is given. If it is, the driver uses its argument but with a suffix of .d, otherwise it take the basename of the input file and applies a .d suffix.
    If -MD is used in conjunction with -E, any -o switch is understood to specify the dependency output file, but if used without -E, each -o is understood to specify a target object file. Since -E is not implied, -MD can be used to generate a dependency output file as a side-effect of
    the compilation process.
    -MMD Like -MD except mention only user header files, not system header files.
    -fpch-deps cause the dependency-output flags to list the files from the precompiled header's dependencies. If not specified only the precompiled header would be listed and not the files that were used to create it
    -fpch-preprocess allows use of a precompiled header with -E.
    Inserts #pragma GCC pch_preprocess filename" to mark the place where the precompiled header was . When -fpreprocessed is in use, GCC recognizes this "#pragma" and loads the PCH. Off by default, the resulting preprocessed output is only suitable as input to GCC. It is on with -save-temps.
    Do not write this "#pragma" in your own code, but it is safe to edit the filename if the PCH file is available in a different location. The filename may be absolute or it may be relative to GCC's current directory.
    -x c
    -x c++
    -x objective-c
    -x objective-c++
    -x assembler-with-cpp
    source base syntax . Normally cpp will deduce the language from the extension . default to C; -ansi
    Specify the standard to which the code should conform.
    "gnu89" 1990 C standard plus GNU extensions. This is the default.
    "gnu99" "gnu9x" 1999 C standard plus GNU extensions.
    "gnu++98" same as -std=c++98 plus GNU extensions. This is the default for C++ code.
    "c89" The ISO C standard from 1990. c89 is the shorthand for this version -ansi is equivalent to -std=c89.
    "c++98" 1998 ISO C++ standard plus amendments.
    "iso9899:199409" 1990 C standard, as amended in 1994.
    "iso9899:1999" "c99" "iso9899:199x" "c9x" revised ISO C standard, December 1999. was known as C9X.
    -I-deprecated. Split the include path. Any directories specified with -I options before -I- are searched only for headers requested with #include "file"; not for #include file.
    If additional directories are specified with -I after -I-, those directories are searched for all #include directives.
    This inhibits using the current directory as the first search directory for "#include "file"".
    include options
    -nostdinc Do not search the standard system directories for header files. Only the directories you have specified with -I options (and the directory of the current file, if appropriate) are searched.
    -nostdinc++ Do not search for header files in the C++-specific standard directories, but do still search the other standard directories. (This option is used when building the C++ library.)
    -include file++ Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.
    If multiple -include options are given, the files are included in the order they appear on the command line.
    -imacros file like -include except that output discarded.
    Macros remain defined. Acquire macros from a header without processing its declarations.
    Files specified by -imacros are processed before -includes.
    -idirafter dir Search dir for header files, but after directories specified with -I and the standard system directories have been exhausted.
    dir is treated as a system include directory.
    -iprefix prefix prefix is used for subsequent -iwithprefix .
    If the prefix represents a directory, include the final /.
    -iwithprefix dir
    -iwithprefixbefore dir
    Append dir to the prefix previous -iprefix!, and
    add the resulting directory to the include search path.
    -iwithprefix puts it where -idirafter would. -iwithprefixbefore puts it in the same place -I would;
    -isystem dirtd> Search dir for header files, after directories specified by -I but
    before the standard system directories.
    Mark it as a system directory, so that it gets the same special treatment
    -iquote dir Search dir only for header files requested with #include "file";
    they are not searched for #include <file>,
    before directories specified by -I and before the standard system directories.
    -fdollars-in-identifiers @anchor{fdollars-in-identifiers} Accept $ in identifiers.
    -fpreprocessed Indicate to the preprocessor that the input file has already been preprocessed. This suppresses things like macro expansion, trigraph conversion, escaped newline splicing, and processing of most directives. The preprocessor still recognizes and removes comments, so that you can pass a file preprocessed with -C to the compiler without problems. In this mode the integrated preprocessor is little more than a tokenizer for the front ends. -fpreprocessed is implicit if the input file has one of the extensions .i, .ii or .mi. These are the extensions that GCC uses for preprocessed files created by -save-temps.
    -ftabstop=width Set the distance between tab stops. This helps the preprocessor report correct column numbers in warnings or errors, even if tabs appear on the line. If the value is less than 1 or greater than 100, the option is ignored. The default is 8.
    -fexec-charset=charset Set the execution character set, used for string and character constants. The default is UTF-8. charset can be any encoding supported by the system's "iconv" library routine.
    -fwide-exec-charset=charset Set the wide execution character set, used for wide string and character constants. The default is UTF-32 or UTF-16, whichever corresponds to the width of "wchar_t". As with -fexec-charset, charset can be any encoding supported by the system's "iconv" library routine; however, you will have problems with encodings that do not fit exactly in "wchar_t".
    -finput-charset=charset Set the input character set, used for translation from the character set of the input file to the source character set used by GCC. If the locale does not specify, or GCC cannot get this information from the locale, the default is UTF-8. This can be overridden by either the locale or this command line option. Currently the command line option takes precedence if there's a conflict. charset can be any encoding supported by the system's "iconv" library routine.
    -fworking-directory Enable generation of linemarkers in the preprocessor output that will let the compiler know the current working directory at the time of preprocessing. When this option is enabled, the preprocessor will emit, after the initial linemarker, a second linemarker with the current working directory followed by two slashes. GCC will use this directory, when it's present in the preprocessed input, as the directory emitted as the current working directory in some debugging information formats. This option is implicitly enabled if debugging information is enabled, but this can be inhibited with the negated form -fno-working-directory. If the -P flag is present in the command line, this option has no effect, since no "#line" directives are emitted whatsoever.
    -fno-show-column Do not output column numbers in diagnostics.
    Used when output is input to another program that does not understand the column numbers, such as dejagnu.
    -P DO not output linemarkers in the output from the preprocessor.
    Useful when running the preprocessor on something that is not C code to be input to another program .
    -A predicate=answer Make an assertion with the predicate predicate and answer answer.
    Preferred to -A predicate(answer),
    Cancel an assertion with the predicate predicate and answer answer.
    -d [M][D][N][I] diagnose #defines.
    -dM… Instead of the normal output,
    generate a list of #define directives for predefined macros and those defined by the preprocessor .
    With an empty file: touch foo.h; cpp -dM foo.h shows the over 400 predefined macros.
    -dD… Like -dM except does not include the predefined macros and outputs both the #define directives and the result of preprocessing to standard output .
    -dN… Like -dD, but output only macro names
    -dI… Output #include directives in addition to the result of preprocessing.
    touch foo.h; cpp -dI foo.h
    # 1 "foo.h"
    # 1 "" 1
    # 1 "" 3
    # 413 "" 3
    # 1 "" 1
    # 1 "" 2
    # 1 "foo.h" 2
    Other characters are interpreted by the compiler proper, or reserved
    -C Do not discard comments. All comments are passed through to the output file, except for comments in processed directives, which are deleted along with the directive. You should be prepared for side effects when using -C; it causes the preprocessor to treat comments as tokens in their own right. For example, comments appearing at the start of what would be a directive line have the effect of turning that line into an ordinary source line, since the first token on the line is no longer a #.
    -CC Do not discard comments, including during macro expansion.
    Like -C, except comments in macros are passed to the output file where the macro is expanded.
    Converts C++- style comments inside a macro to C-style preventing later use of that macro from inadvertently commenting out the remainder of the source line.
    Used to support lint comments.
    -traditional-cpp imitate old C preprocessors, as opposed to ISO C preprocessors.
    -trigraphs Process trigraph sequences to stand for single character. Ignored by default. In standard-conforming modes they are converted . See -std and -ansi The nine trigraphs and their replacements are:
                       Trigraph:       ??(  ??)  ??<  ??>  ??=  ??/  ??'  ??!  ??-
                       Replacement:      [    ]    {    }    #    \    ^    |    ~
    -remap Enable special code to handle file systems which only permit short file names, such as MS-DOS.
    --help --target-help Output text describing the command line options
    -v Verbose mode. Output version number and report the final form of the include path.
    -H Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the #include stack it is. Precompiled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with ...x and a valid one with ...! .
    -version --version output GNU CPP's version number. With one dash, proceed to preprocess as normal. With two dashes, exit immediately.

    Passing Options to the Assembler

    You can pass options to the assembler.
    -Wa,option Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.
    -Xassembler option Pass option as an option to the assembler. You can use this to supply system-specific assembler options which GCC does not know how to recognize. If you want to pass an option that takes an argument, you must use -Xassembler twice, once for the option and once for the argument.

    Options for Linking

    Apple's GCC also accepts and passes the options defined by the linker ld and by the library tool libtool.
    Common options include -framework, -dynamic, -bundle, -flat_namespace, and so forth. See ld and libtool
    object-file-name A file name that does not end in a special recognized suffix is considered to name an object file or library. (Object files are distinguished from libraries by the linker according to the file contents.) If linking is done, these object files are used as input to the linker.
    the linker is not run, and object file names should not be used as arguments.
    -llibrary Search libraries and object files in order.
    The linker searches a standard list of directories for the library, liblibrary.a.
    The directories searched include standard system directories plus any specified with -L.
    library files are archive files whose members are object files. The linker handles by scanning it for members which define symbols that have so far been referenced but not defined.
    if the file that is found is an object file, it is linked in the usual fashion.
    The difference between using -l and specifying a file name is that -l surrounds library with lib and .a and searches several directories.
    -lobjc special case of -l to link an Objective-C or Objective-C++ program.
    -nostartfiles Do not use the standard system startup files .
    The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used.
    -nodefaultlibs Do not use the standard system libraries . The standard startup files are used normally, unless -nostartfiles is used.
    The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries in libc. These entry points must be supplied with this option
    -nostdlib Do not use the standard system startup files or libraries . No startup files and only the libraries specifed will be passed to the linker.
    The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified.

    One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is libgcc.a,

    which is needed a even when avoiding other standard libraries. when you specify -nostdlib or -nodefaultlibs you should usually specify -lgcc

    -pie Produce a position independent executable . Specify the same set of options used to generate code (-fpie, -fPIE, or model suboptions)
    -s Remove symbol table and relocation information from the executable.
    -static prevents linking with the shared libraries. On Mac OS all libraries (including libgcc.a) have also been compiled with -static.
    -shared Produce a shared object which can then be linked with other objects to form an executable. also specify the same set of options that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.[1]
    Not supported on Mac OS .
    force the use of either the shared or static version

    drivers add -shared-libgcc whenever buildding a shared library or a main executable, because C++ and Java programs typically use exceptions,

    using the GCC driver to create shared libraries, they will not always be linked with the shared libgcc. If GCC finds, at its configuration time, that you have a non-GNU linker or a GNU linker that does not support option --eh-frame-hdr, it will link the shared version of libgcc into shared libraries by default. Otherwise, it will take advantage of the linker and optimize away the linking with the shared version of libgcc, linking with the static version of libgcc by default. This allows exceptions to propagate through such shared libraries, without incurring relocation costs at library load time.

    if a library or main executable is supposed to throw or catch exceptions, link it using the G++ or GCJ driver, the option -shared-libgcc, with the shared libgcc.

    -symbolic Bind references to global symbols when building a shared object. Warn about any unresolved references (unless overridden by the -Xlinker -z -Xlinker defs).
    -Xlinker option Pass option to the linker. which GCC does not know
    to pass an option that takes an argument, use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions.
    -Wl,option Pass an option to the linker.
    -u symbol Treat the symbol as undefined, to force linking of library modules to define it. May be used multiple times to force loading of additional library modules.

    Options for Directory Search

    directories to search for header files, for libraries and for parts of the compiler:
    -Idir Add dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. Do not use to add directories that contain vendor-supplied system header files (use -isystem for that). With than one -I the directories are scanned in left-to-right order; the standard system directories come after.

    If a standard system include directory, or a directory specified with -isystem, is also specified with -I, -I will be ignored. The directory will still be searched but as a system directory at its normal position in the system include chain. This is to ensure that GCC's procedure to fix buggy system headers and the ordering for the include_next directive are not inadvertently changed. To change the search order for system directories, use the -nostdinc and/or -isystem .

    -iquotedir dir Add dir to the head of the list of directories to be searched for header files only for the case of #include "file"; they are not searched for #include file, otherwise just like -I.
    -Ldir Add dir,/code> to the list of directories to be searched for -l.
    -Bprefix specifies where to find the executables, libraries, include files, and data files of the compiler itself.

    The compiler driver program runs one or more of cpp, cc1, as and ld. It tries prefix for each program it tries to run, both with and without machine/version/.

    the compiler driver first tries the -B prefix, If that name is not found, or if -B was not specified, the driver tries two standard prefixes, which are /usr/lib/gcc/ and /usr/local/lib/gcc/. If neither of those results in a file name that is found, the unmodified program name is searched for using the directories specified in your $PATH

    The compiler will check to see if the path provided by the -B refers to a directory, and if necessary it will add a directory separator character at the end of the path.

    -B prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into -L for the linker. They also apply to includes files in the preprocessor, because the compiler translates these options into -isystem for the preprocessor. In this case, the compiler appends include to the prefix.

    The run-time support file libgcc.a can also be searched for using the -B prefix, if needed. If it is not found there, the two standard prefixes are tried, . The file is left out of the link if it is not found by those means.

    Another way to specify a prefix to use the $GCC_EXEC_PREFIX.

    if the path provided by -B is [dir/]stageN/, where N it will be replaced by [dir/]include. This is to help with boot-strapping the compiler.

    -specs=file Process file after the compiler reads in the standard specs file, to override the defaults that the gcc driver program uses when determining what switches to pass to cc1, cc1plus, as, ld, etc. More than one -specs can be specified on the command line, and are processed in order,

    Specifying Target Machine and Compiler Version

    The usual way to run GCC is to run the executable called gcc, or machine-gcc when cross-compiling, or machine>-gcc-version> to run a version other than the one that was installed last. GCC provides options that will switch to another cross-compiler or version.
    -b machine The argument machine specifies the target machine for compilation.

    The value to use for machine is the same as was specified as the machine type when configuring GCC as a cross-compiler. For example, if a cross-compiler was configured with configure i386v, meaning to compile for an 80386 running System V, then you would specify -b i386v to run that cross compiler.

    -V version which version of GCC to run when multiple versions are installed. For example, version might be 2.0, meaning to run GCC version 2.0.
    -V and -b run the machine>-gcc-version> executable,

    Hardware Models and Configurations

    Each of these target machine types can have its own special options, starting with -m, to choose among various hardware models or configurations---for example, 68010 vs 68020, floating coprocessor or none. A single installed version of the compiler can compile for any model or configuration, according to the options specified.

    Some configurations of the compiler also support additional special options, usually for compatibility with other compilers on the same platform.

    These options are defined by the macro "TARGET_SWITCHES" in the machine description. The default for the options is also defined by that macro, which enables you to change the defaults.

    ARM Options

    Advanced RISC Machines

    -mabi=name Generate code for the specified ABI. apcs-gnu, atpcs, aapcs and iwmmxt.
    Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions, -fomit-frame-pointer with this will cause the stack frames not to be generated for leaf functions. The default is -mno-apcs-frame.
    -mthumb-interwork Generate code which supports calling between the ARM and Thumb instruction sets. Without this option the two instruction sets cannot be reliably used inside one program. The default is -mno-thumb-interwork
    -mno-sched-prolog Prevent the reordering of instructions in the function prolog, or the merging of those instruction with the instructions in the function's body. This means that all functions will start with a recognizable set of instructions (or in fact one of a choice from a small set of different function prologues), and this information can be used to locate the start if functions inside an executable piece of code. The default is -msched-prolog.
    -mhard-float Generate output containing floating point instructions. This is the default.
    -msoft-float Generate output containing library calls for floating point.
    Not available for all ARM targets. Normally the facilities of the machine's usual C compiler are used, but this cannot be done directly in cross-compilation. You must make your own -msoft-float changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile libgcc.a, the library that comes with GCC, with -msoft-float in order for this to work.
    -mfloat-abi=name Specifies which ABI to use for floating point values. soft| softfp |hard. soft and hard are equivalent to -msoft-float and -mhard-float respectively. softfp allows the generation of floating point instructions, but still uses the soft-float calling conventions.
    -mlittle-endian Generate code for a processor running in little-endian mode. This is the default
    -mbig-endian Generate code for a processor running in big-endian mode;
    -mcpu=name This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. Permissible names are: arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, arm7100, arm7500, arm7500fe, arm7tdmi, arm7tdmi-s, arm8, strongarm, strongarm110, strongarm1100, arm8, arm810, arm9, arm9e, arm920, arm920t, arm922t, arm946e-s, arm966e-s, arm968e-s, arm926ej-s, arm940t, arm9tdmi, arm10tdmi, arm1020t, arm1026ej-s, arm10e, arm1020e, arm1022e, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp, arm1176jz-s, arm1176jzf-s, xscale, iwmmxt, ep9312.
    -mtune=name similar to -mcpu , except that instead of specifying the actual target processor type, GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instructions that it will generate based on the cpu specified by a -mcpu= option. For some ARM implementations better performance can be obtained by using this option.
    -march=name This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option can be used in conjunction with or instead of the -mcpu= option. Permissible names are: armv2, armv2a, armv3, armv3m, armv4, armv4t, armv5, armv5t, armv5te, armv6, armv6j, iwmmxt, ep9312.
    -mfpu=name -mfpe=number -mfp=number specifies what floating point hardware (or hardware emulation) is available on the target. Permissible names are: fpa, fpe2, fpe3, maverick, vfp. If -msoft-float is specified this specifies the format of floating point values.
    -mstructure-size-boundary=n The size of all structures and unions will be rounded up to a multiple of the number of bits set by this option. Permissible values are 8, 32 and 64. The default value varies for different toolchains. For the COFF targeted toolchain the default value is 8.

    Specifying the larger number can produce faster, more efficient code, but can also increase the size of the program. Different values are potentially incompatible. Code compiled with one value cannot necessarily expect to work with code or libraries compiled with another value, if they exchange information using structures or unions.

    -mabort-on-noreturn Generate a call to the function "abort" at the end of a "noreturn" function. It will be executed if the function tries to return.
    -mlong-calls -mno-long-calls Tells the compiler to perform function calls by first loading the address of the function into a register and then performing a subroutine call on this register. This switch is needed if the target function will lie outside of the 64 megabyte addressing range of the offset based version of subroutine call instruction. Even if this switch is enabled, not all function calls will be turned into long calls. The heuristic is that static functions, functions which have the short-call attribute, functions that are inside the scope of a #pragma no_long_calls directive and functions whose definitions have already been compiled within the current compilation unit, will not be turned into long calls. The exception to this rule is that weak function definitions, functions with the long-call attribute or the section attribute, and functions that are within the scope of a #pragma long_calls directive, will always be turned into long calls. This feature is not enabled by default. Specifying -mno-long-calls will restore the default behavior, as will placing the function calls within the scope of a #pragma long_calls_off directive. Note these switches have no effect on how the compiler generates code to handle function calls via function pointers.
    -mnop-fun-dllimport Disable support for the "dllimport" attribute.
    -msingle-pic-base Treat the register used for PIC addressing as read-only, rather than loading it in the prologue for each function. The run-time system is responsible for initializing this register with an appropriate value before execution begins.
    -mpic-register=reg Specify the register to be used for PIC addressing. The default is R10 unless stack-checking is enabled, when R9 is used.
    -mcirrus-fix-invalid-insns Insert NOPs into the instruction stream to in order to work around problems with invalid Maverick instruction combinations. This option is only valid if the -mcpu=ep9312 option has been used to enable generation of instructions for the Cirrus Maverick floating point co-processor. This option is not enabled by default, since the problem is only present in older Maverick implementations. The default can be re-enabled by use of the -mno-cirrus-fix-invalid-insns switch.
    -mpoke-function-name Write the name of each function into the text section, directly preceding the function prologue. The generated code is similar to this:
                                .ascii "arm_poke_function_name", 0
                                .word 0xff000000 + (t1 - t0)
                                mov     ip, sp
                                stmfd   sp!, {fp, ip, lr, pc}
                                sub     fp, ip, #4
    When performing a stack backtrace, code can inspect the value of "pc" stored at "fp + 0". If the trace function then looks at location "pc - 12" and the top 8 bits are set, then we know that there is a function name embedded immediately preceding this location and has length "((pc[-3]) & 0xff000000)".
    -mthumb Generate code for the 16-bit Thumb instruction set. The default is to use the 32-bit ARM instruction set.
    -mtpcs-frame Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all non-leaf functions. (A leaf function is one that does not call any other functions.) The default is -mno-tpcs-frame.
    -mtpcs-leaf-frame Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all leaf functions. (A leaf function is one that does not call any other functions.) The default is -mno-apcs-leaf-frame.
    -mcallee-super-interworking Gives all externally visible functions in the file being compiled an ARM instruction set header which switches to Thumb mode before executing the rest of the function. This allows these functions to be called from non-interworking code.
    -mcaller-super-interworking Allows calls via function pointers (including virtual functions) to execute correctly regardless of whether the target code has been compiled for interworking or not. There is a small overhead in the cost of executing a function pointer if this option is enabled.

    Darwin Options

    These options are defined for all architectures running the Darwin operating system. FSF GCC on Darwin does not create universal object files; it will create an object file for the single architecture that it was built to target. Apple's GCC on Darwin does create universal files if multiple -arch options are used; it does so by running the compiler or linker multiple times and joining the results together with lipo.

    The subtype of the file created (like ppc7400 or ppc970 or i686) is determined by the flags that specify the ISA that GCC is targetting, like -mcpu or -march. The -force_cpusubtype_ALL can be used to override this.

    The Darwin tools vary in their behavior when presented with an ISA mismatch. The assembler, as, will only permit instructions to be used that are valid for the subtype of the file it is generating, so you cannot put 64-bit instructions in an ppc750 object file. The linker for shared libraries, /usr/bin/libtool, will fail and print an error if asked to create a shared library with a less restrictive subtype than its input files (for instance, trying to put a ppc970 object file in a ppc7400 library). The linker for executables, ld, will quietly give the executable the most restrictive subtype of any of its input files.

    -fdir dif Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with those specified by -I and are scanned in a left-to-right order.

    A framework is a directory with a "Headers" and/or "PrivateHeaders" directory contained directly in it that ends in ".framework". The name of a framework is the name of this directory excluding the ".framework".
    Headers associated with the framework are found in one of those two directories, with "Headers" being searched first.
    A subframework is a framework directory that is in a framework's "Frameworks" directory. Includes of subframework headers can only appear in a header of a framework that contains the subframework, or in a sibling subframework header. Two subframeworks are siblings if they occur in the same framework. A subframework should not have the same name as a framework, a warning will be issued if this is violated. Currently a subframework cannot have subframeworks,
    The standard frameworks are in "/System/Library/Frameworks" and "/Library/Frameworks".
    An example include "#include ", where Framework denotes the name of the framework and header.h is found in the "PrivateHeaders" or "Headers" directory.

    -iframeworkdir Like -F except the directory is a treated as a system directory. The main effect is to not warn about constructs contained within header files found via dir.
    -gused Emit debugging information for used symbols. For STABS debugging format, this enables -feliminate-unused-debug-symbols. Default ON.
    -gfull Emit debugging information for all symbols and types.
    -mmacosx-version-min=version The earliest version of MacOS X that this executable will run . Typical values of version include 10.1, 10.2, and 10.3.9.

    If the compiler was built to use the system's headers by default, then the default for this option is the system version on which the compiler is running, otherwise the default is to make choices which are compatible with as many systems and code bases as possible.

    -mkernel Enable kernel development mode. sets -static, -fno-common, -fno-cxa-atexit, -fno-exceptions, -fno-non-call-exceptions, -fapple-kext, -fno-weak and -fno-rtti where applicable. This mode also sets -mno-altivec, -msoft-float, -fno-builtin and -mlong-branch for PowerPC targets.
    -mfix-and-continue Generate code suitable for fast turn around development. Needed to enable gdb to dynamically load ".o" files into already running programs.
    -all_load Loads all members of static archive libraries. See ld
    -arch_errors_fatal errors related to the wrong architecture are fatal.
    -bind_at_load output marked so the dynamic linker will bind undefined references when the file is loaded
    -bundle Produce a Mach-o bundle format file. See ld
    -bundle_loader executable executable will be loading the build output file being linked. ld
    -dynamiclib produce a dynamic library using the Darwin libtool
    -force_cpusubtype_ALL output file has the ALL subtype
    -allowable_client client_name
    are passed to the Darwin linker.
    -masm=dialect Output asm instructions using selected dialect. Supported choices are intel or att (the default one). Darwin does not support intel.
    -mno-ieee-fp Control whether or not the compiler uses IEEE floating point comparisons. These handle correctly the case where the result of a comparison is unordered.
    -msoft-float Generate output containing library calls for floating point. Warning: the requisite libraries are not part of GCC. Normally the facilities of the machine's usual C compiler are used, but this can't be done directly in cross-compilation. You must make your own arrangements to provide suitable library functions for cross-compilation. On machines where a function returns floating point results in the 80387 register stack, some floating point opcodes may be emitted even if -msoft-float is used.
    -mno-fp-ret-in-387 Do not use the FPU registers for return values of functions. The usual calling convention has functions return values of types "float" and "double" in an FPU register, even if there is no FPU. The idea is that the operating system should emulate an FPU. The option -mno-fp-ret-in-387 causes such values to be returned in ordinary CPU registers instead.
    -mno-align-double Control whether GCC aligns "double", "long double", and "long long" variables on a two word boundary or a one word boundary. Aligning "double" variables on a two word boundary will produce code that runs somewhat faster on a Pentium at the expense of more memory. Warning: if you use the -malign-double switch, structures containing the above types will be aligned differently than the published application binary interface specifications for the 386 and will not be binary compatible with structures in code compiled without that switch.
    -m96bit-long-double -m128bit-long-double These switches control the size of "long double" type. The i386 application binary interface specifies the size to be 96 bits, so -m96bit-long-double is the default in 32 bit mode.

    Modern architectures (Pentium and newer) would prefer "long double" to be aligned to an 8 or 16 byte boundary. In arrays or structures conforming to the ABI, this would not be possible. So specifying a -m128bit-long-double will align "long double" to a 16 byte boundary by padding the "long double" with an additional 32 bit zero.

    In the x86-64 compiler, -m128bit-long-double is the default choice as its ABI specifies that "long double" is to be aligned on 16 byte boundary.

    Notice that neither of these options enable any extra precision over the x87 standard of 80 bits for a "long double".

    Warning: if you override the default value for your target ABI, the structures and arrays containing "long double" variables will change their size as well as function calling convention for function taking "long double" will be modified. Hence they will not be binary compatible with arrays or structures in code compiled without that switch.

    no-svr3-shlib Control whether GCC places uninitialized local variables into the "bss" or "data" segments. -msvr3-shlib places them into "bss". These options are meaningful only on System V Release 3.
    -mrtd Use a different function-calling convention, in which functions that take a fixed number of arguments return with the "ret" num instruction, which pops their arguments while returning. This saves one instruction in the caller since there is no need to pop the arguments there. You can specify that an individual function is called with this calling sequence with the function attribute stdcall. You can also override the -mrtd option by using the function attribute cdecl. Warning: this calling convention is incompatible with the one normally used on Unix, so you cannot use it if you need to call libraries compiled with the Unix compiler. Also, you must provide function prototypes for all functions that take variable numbers of arguments (including "printf"); otherwise incorrect code will be generated for calls to those functions. In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)
    -mregparm=num Control how many registers are used to pass integer arguments. By default, no registers are used to pass arguments, and at most 3 registers can be used. You can control this behavior for a specific function by using the function attribute regparm. Warning: if you use this switch, and num is nonzero, then you must build all modules with the same value, including any libraries. This includes the system libraries and startup modules.
    -mstackrealign Realign the stack at entry. On the Intel x86, the -mstackrealign option will generate an alternate prologue/epilogue that realigns the runtime stack. This supports mixing legacy codes that keep a 4-byte aligned stack with modern codes that keep a 16-byte stack for SSE compatibility. The alternate prologue and epilogue are slower and bigger than the regular ones, and they require one dedicated register for the entire function. This also lowers the number of registers available if used in conjunction with the "regparm" attribute. Nested functions encountered while -mstackrealign is on will generate warnings, and they will not realign the stack when called.
    -mpreferred-stack-boundary=num Attempt to keep the stack boundary aligned to a 2 raised to num byte boundary. If -mpreferred-stack-boundary is not specified, the default is 4 (16 bytes or 128 bits), except when optimizing for code size (-Os or -Oz ), in which case the default is the minimum correct alignment (4 bytes for x86, and 8 bytes for x86-64).

    On Pentium and PentiumPro, "double" and "long double" values should be aligned to an 8 byte boundary (see -malign-double) or suffer significant run time performance penalties. On Pentium III, the Streaming SIMD Extension (SSE) data type "__m128" suffers similar penalties if it is not 16 byte aligned.

    To ensure proper alignment of this values on the stack, the stack boundary must be as aligned as that required by any value stored on the stack. Further, every function must be generated such that it keeps the stack aligned. Thus calling a function compiled with a higher preferred stack boundary from a function compiled with a lower preferred stack boundary will most likely misalign the stack. It is recommended that libraries that use callbacks always use the default setting.

    This extra alignment does consume extra stack space, and generally increases code size. Code that is sensitive to stack space usage, such as embedded systems and operating system kernels, may want to reduce the preferred alignment to -mpreferred-stack-boundary=2.

    -mno-mmx -mno-sse
    These switches enable or disable the use of built-in functions that allow direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the instruction set. To have SSE/SSE2 instructions generated automatically from floating-point code, see -mfpmath=sse.
    -mno-push-args Use PUSH operations to store outgoing parameters. This method is shorter and usually equally fast as method using SUB/MOV operations and is enabled by default. In some cases disabling it may improve performance because of improved scheduling and reduced dependencies.
    -maccumulate-outgoing-args If enabled, the maximum amount of space required for outgoing arguments will be computed in the function prologue. This is faster on most modern CPUs because of reduced dependencies, improved scheduling and reduced stack usage when preferred stack boundary is not equal to 2. The drawback is a notable increase in code size. This switch implies -mno-push-args.
    -mthreads Support thread-safe exception handling on Mingw32. Code that relies on thread-safe exception handling must compile and link all code with the -mthreads option. When compiling, -mthreads defines -D_MT; when linking, it links in a special thread helper library -lmingwthrd which cleans up per thread exception handling data.
    -mno-align-stringops Do not align destination of inlined string operations. This switch reduces code size and improves performance in case the destination is already aligned, but GCC doesn't know about it.
    -minline-all-stringops By default GCC inlines string operations only when destination is known to be aligned at least to 4 byte boundary. This enables more inlining, increase code size, but may improve performance of code that depends on fast memcpy, strlen and memset for short lengths.
    -momit-leaf-frame-pointer Don't keep the frame pointer in a register for leaf functions. This avoids the instructions to save, set up and restore frame pointers and makes an extra register available in leaf functions. The option -fomit-frame-pointer removes the frame pointer for all functions which might make debugging harder.
    -mno-tls-direct-seg-refs Controls whether TLS variables may be accessed with offsets from the TLS segment register (%gs for 32-bit, %fs for 64-bit), or whether the thread base pointer must be added. Whether or not this is legal depends on the operating system, and whether it maps the segment to cover the entire TLS area. For systems that use GNU libc, the default is on.
    enables or disables the generation of ISEL instructions.
    enables or disables the generation of SPE simd instructions.
    -m32 -m64 Generate code for 32-bit or 64-bit environments of Darwin and SVR4 targets (including GNU/Linux). The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any PowerPC variant. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits, and generates code for PowerPC64, as for -mpowerpc64.
    Modify generation of the TOC (Table Of Contents), which is created for every executable file. The -mfull-toc option is selected by default. In that case, GCC will allocate at least one TOC entry for each unique non-automatic variable reference in your program. GCC will also place floating-point constants in the TOC. However, only 16,384 entries are available in the TOC.

    If you receive a linker error message that saying you have overflowed the available TOC space, you can reduce the amount of TOC space used with the -mno-fp-in-toc and -mno-sum-in-toc options. -mno-fp-in-toc prevents GCC from putting floating-point constants in the TOC and -mno-sum-in-toc forces GCC to generate code to calculate the sum of an address and a constant at run-time instead of putting that sum into the TOC. You may specify one or both of these options. Each causes GCC to produce very slightly slower and larger code at the expense of conserving TOC space.

    If you still run out of space in the TOC even when you specify both of these options, specify -mminimal-toc instead. This option causes GCC to make only one TOC entry for every file. When you specify this option, GCC will produce code that is slower and larger but which uses extremely little TOC space. You may wish to use this option only on files that contain less frequently executed code.

    -maix64 -maix32 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit "long" type, and the infrastructure needed to support them. Specifying -maix64 implies -mpowerpc64 and -mpowerpc, while -maix32 disables the 64-bit ABI and implies -mno-powerpc64. GCC defaults to -maix32.
    -mno-xl-compat Produce code that conforms more closely to IBM XLC semantics when using AIX-compatible ABI. Pass floating-point arguments to prototyped functions beyond the register save area (RSA) on the stack in addition to argument FPRs. Do not assume that most significant double in 128 bit long double value is properly rounded when comparing values. The AIX calling convention was extended but not initially documented to handle an obscure K&R C case of calling a function that takes the address of its arguments with fewer arguments than declared. AIX XL compilers access floating point arguments which do not fit in the RSA from the stack when a subroutine is compiled without optimization. Because always storing floating-point arguments on the stack is inefficient and rarely needed, this option is not enabled by default and only is necessary when calling subroutines compiled by AIX XL compilers without optimization.
    -mpe Support IBM RS/6000 SP Parallel Environment (PE). Link an application written to use message passing with special startup code to enable the application to run. The system must have PE installed in the standard location (/usr/lpp/ppe.poe/), or the specs file must be overridden with the -specs= option to specify the appropriate directory location. The Parallel Environment does not support threads, so the -mpe option and the -pthread option are incompatible.
    Hardware instructions options
    -msoft-float Generate code that does not use the floating-point register set rather use emulation library.
    Library modules are not shipped on Apple PowerPCs.
    Prevents uses of floating point registers in unexpected contexts, for example, copying memory to memory.
    -mhard-float use floating-point register set.
    -mno-multiple Use (do not use) the load/store multiple word.
    Do not use multiple on little endian PowerPC systems,
    -mno-string Use (do not use) the load/store string to save multiple registers and do small block moves.
    These instructions are generated by default on POWER systems, and not generated on PowerPC systems.
    Do not use -mstring on little endian PowerPC systems,
    -m`no-update Uses (does not use) the load/store that update the base register to the address of the calculated memory location.
    These are generated by default.
    With -mno-update , there is a window between the time that the stack pointer is updated and the address of the previous frame is stored, which means code that walks the stack frame across interrupts or signals may get corrupted data.
    -mno-fused-madd Generate code that uses (does not use) the floating point multiply and accumulate instructions. These instructions are generated by default if hardware floating is used.
    Memory alignment
    -malign-natural overrides ABI-defined alignment of larger types, such as floating-point doubles, on their natural size- based boundary on AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux,
    On 64-bit Darwin, align-natural is the default,
    -malign-power follow ABI-specified alignment rules.
    Defaults . Not for 64-bit Darwin,
    -mno-bit-align Do not (do) force structures and unions that contain bit-fields to be aligned to the base type of the bit-field, On System V.4 and embedded PowerPC systems
    For example, a structure containing nothing but 8 "unsigned" bit-fields of length 1 would be aligned to a 4 byte boundary and have a size of 4 bytes. With -mno-bit-align, the structure would be aligned to a 1 byte boundary and be one byte in size.
    System V.4 and embedded PowerPC options
    -mno-strict-align do not (do) assume that unaligned memory references will be handled by the system.
    -mno-toc do not (do) expect register 2 to contain a pointer to a global area pointing to the addresses used in the program.
    code for the processor in little endian mode.
    compile code for the processor in big endian mode.
    -mnoeabi (do not) adhere to the Embedded Applications Binary Interface (eabi) a set of modifications to the System V.4 specifications. Selecting
    -meabi: the stack is aligned to an 8 byte boundary, a function "__eabi" is called to from "main" to set up the eabi environment, and the -msdata option can use both "r2" and "r13" to point to two separate small data areas.
    -mno-eabi: the stack is aligned to a 16 byte boundary, do not call an initialization function from "main", and the -msdata option will only use "r13" to point to a single small data area.
    Default -meabi if you configured GCC using one of the powerpc*-*-eabi* options.
    -msdata=eabi put small initialized "const" global and static data in the .sdata2 section, which is pointed to by register "r2". Put small initialized non-"const" global and static data in the .sdata section, which is pointed to by register "r13". Put small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section.
    -msdata=eabi is incompatible with the -mrelocatable option.
    sets -memb .
    if -meabi is used, compile code the same as -msdata=eabi, otherwise compile code the same as -msdata=sysv.
    -msdata-data put small global and static data in the .sdata section.
    Put small uninitialized global and static data in the .sbss section.
    Do not use register "r13" to address small data however. This is the default behavior unless other -msdata options are used.
    -mno-regnames do (do not) emit register names in the assembly language output using symbolic forms.
    embedded PowerPC options
    -mno-relocatable PositionIndependentCode (PIC) allows (does not allow) the program to be relocated to a various addresss at runtime. With -mrelocatable on any module, all objects linked together must be compiled with -mrelocatable or -mrelocatable-lib.
    -mno-relocatable-lib allows (does not allow) the program to be relocated to a different address at runtime.
    Modules compiled with -mrelocatable-lib can be linked with either modules compiled without -mrelocatable and -mrelocatable-lib or with modules compiled with the -mrelocatable
    -mdynamic-no-pic On Darwin and Mac OS , compile code so that it is not relocatable, but that its external references are relocatable. The resulting code is suitable for applications, but not shared libraries.
    -mprioritize-restricted-insns=[0|1|2] priority that is assigned to dispatch-slot restricted instructions during the second scheduling pass. no/highest/second-highest priority
    -msched-costly-dep=type dependences are considered costly by the target during instruction scheduling. no: no dependence is costly, all: all dependences are costly, true_store_to_load: a true dependence from store to load is costly, store_to_load: any dependence from store to load is costly, n: any dependence which latency >= n is costly.
    -minsert-sched-nops=scheme which nop insertion scheme will be used during the second scheduling pass.
    no: Don't insert nops.
    pad: Pad with nops any dispatch group which has vacant issue slots, according to the scheduler's grouping.
    regroup_exact: Insert nops to force costly dependent insns into separate groups. Insert exactly as many nops as needed to force an insn to a new group, according to the estimated processor grouping.
    n: Insert nops to force costly dependent insns into separate groups. Insert number nops to force an insn to a new group.
    -maix-struct-return Return all structures in memory (as specified by the AIX ABI).
    <-msvr4-struct-return Return structures smaller than 8 bytes in registers (as specified by the SVR4 ABI).
    -mabi=altivec Extend the current ABI with AltiVec ABI extensions. This does not change the default ABI, instead it adds the AltiVec ABI extensions to the current ABI.
    -mabi=no-altivec Disable AltiVec ABI extensions for the current ABI.
    Default make function calls indirectly, using a register, enabling destinations further than 32 megabytes from the current location.
    This setting can be overridden by the "shortcall" function attribute, or by "#pragma longcall(0)".

    Some linkers are capable of detecting out-of-range calls and generating glue code on the fly. On these systems, long calls are unnecessary and generate slower code. As of this writing, the AIX linker can do this, as can the GNU linker for PowerPC/64. It is planned to add this feature to the GNU linker for 32-bit PowerPC systems as well.

    On Darwin/PPC systems, "#pragma longcall" will generate jbsr callee, L42, plus a branch island (glue code). The two target addresses represent the callee and the branch island. The Darwin/PPC linker will prefer the first address and generate a bl callee if the PPC bl instruction will reach the callee directly; otherwise, the linker will generate bl L42 to call the branch island. The branch island is appended to the body of the calling function; it computes the full 32-bit address of the callee and jumps to it.

    On Mach-O (Darwin) systems, -mlongcall directs the compiler emit to the glue for every direct call, and the Darwin linker decides whether to use or discard it. -mlong-branch is a synonym for -mlongcall. In the future, we may cause GCC to ignore all longcall specifications when the linker is known to generate glue.

    -pthread Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.
    Code Generation Conventions
    These machine-independent options control the interface conventions used in code generation. the one which is not the default.
    -fbounds-check generate additional code to check that indices used to access arrays are within the declared range. Only Java(true) and Fortran 77(false)
    -ftrapv generates traps for signed overflow on addition, subtraction, multiplication
    -fwrapv signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation.
    Enables some optimizations and disables other. enabled by default for Java
    -fexceptions Enable exception handling. Generates extra code needed to propagate exceptions. For some targets,
    generate frame unwind information for all functions, which can produce significant data size overhead, Default enable for languages like C++ which normally require exception handling, and
    disable it for languages like C that do not normally require it.
    -fnon-call-exceptions allows trapping instructions to throw exceptions.
    Only allows trapping instructions to throw exceptions, i.e. memory references or floating point instructions.
    Not exceptions thrown from signal handlers such as "SIGALRM".
    -fasynchronous-unwind-tables Generate dwarf2 unwind table
    -fpcc-struct-return Return short "struct" and "union" values in memory like longer ones, rather than in registers.
    -freg-struct-return Return "struct" and "union" values in registers when possible.
    -fshort-enums Allocate to an "enum/code>" type only as many bytes as it needs for the declared range of possible values.
    -fshort-double Use the same size for "double" as for "float".
    -fshort-wchar Override the underlying type for wchar_t to be short unsigned int instead of the default for the target.
    -fshared-data data and non-"const" variables be shared data rather than private data.
    -fno-common In C, allocate uninitialized global variables in the data section, rather than common blocks. The same variable declared (without "extern") in two different compilations, produces an error when linked .
    -fno-ident Ignore #ident
    -fverbose-asm extra comments in the generated assembly code
    -fpic Generate Position-Independent Code (PIC) suitable for use in a shared library, All accesses to constant addresses are hrough a global offset table (GOT).
    The dynamic loader resolves the GOT entries when the program starts Not supported on Mac OS X.
    -fPIC emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table.
    The default on Darwin and Mac OS X.
    -fPIE These options are similar to pic and PIC, but generated position independent code can be only linked into executables.
    -ffixed-reg reg Treat the register named reg as a fixed register; generated code should never refer to it (except perhaps as a stack pointer, frame pointer or in some other fixed role).
    reg must be the name of a register. defined in the "REGISTER_NAMES" macro in the machine description macro file.
    -fcall-used-reg reg as an allocable register clobbered by function calls. It may be allocated for temporaries or variables that do not live across a call. Functions compiled this way will not save and restore the register reg. It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results.
    -fcall-saved-reg Treat the register named reg as an allocable register saved by functions. It may be allocated even for temporaries or variables that live across a call. Functions compiled this way will save and restore the register reg if they use it.
    It is an error to used this flag with the frame pointer or stack pointer. Use of this flag for other registers that have fixed pervasive roles in the machine's execution model will produce disastrous results.
    -fpack-struct[=n] Without a value specified, pack all structure members together without holes.
    When a value is specified (which must be a small power of two), pack structure members according to this value, representing the maximum alignment (that is, objects with default alignment requirements larger than this will be output potentially unaligned at the next fitting location.
    -finstrument-functions Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, the following profiling functions will be called with the address of the current function and its call site. (On some platforms, "__builtin_return_address" does not work beyond the current function, so the call site information may not be available to the profiling functions otherwise.)
                       void __cyg_profile_func_enter (void *this_fn,
                                                      void *call_site);
                       void __cyg_profile_func_exit  (void *this_fn,
                                                      void *call_site);
    The first argument is the address of the start of the current function, which may be looked up exactly in the symbol table.

    This instrumentation is also done for functions expanded inline in other functions. The profiling calls will indicate where, conceptually, the inline function is entered and exited. This means that addressable versions of such functions must be available. If all your uses of a function are expanded inline, this may mean an additional expansion of code size. If you use extern inline in your C code, an addressable version of such functions must be provided. (This is normally the case anyways, but if you get lucky and the optimizer always expands the functions inline, you might have gotten away without providing static copies.)

    A function may be given the attribute "no_instrument_function", in which case this instrumentation will not be done. This can be used, for example, for the profiling functions listed above, high-priority interrupt routines, and any functions from which the profiling functions cannot safely be called (perhaps signal handlers, if the profiling routines generate output or allocate memory).

    -fstack-check verify not go beyond the boundary of the stack. only rarely need to specify it in a single-threaded environment since stack overflow is automatically detected on many systems if there is only one stack. Does not actually cause checking, ; the operating system must do generation of code to ensure that the operating system sees the stack being extended.
    -fno-stack-limit Generate code to ensure that the stack does not grow beyond a certain value, either the value of a register or the address of a symbol.
    If the stack would grow beyond the value, a signal is raised. For most targets, the signal is raised before the stack overruns the boundary, so it is possible to catch the signal without taking special precautions. For instance, if the stack starts at absolute address 0x80000000 and grows downwards, you can use the flags -fstack-limit-symbol=__stack_limit and -Wl,--defsym,__stack_limit=0x7ffe0000 to enforce a stack limit of 128KB. only work with the GNU linker.
    Specify the possible relationships among parameters and between parameters and global data.
    -fargument-alias arguments (parameters) may alias each other and may alias global storage.-fargument-noalias specifies that arguments do not alias each other, but may alias global storage.-fargument-noalias-global specifies that arguments do not alias each other and do not alias global storage. Each language will automatically use whatever option is required by the language standard. You should not need to use these options yourself.
    -fleading-underscore and its counterpart, -fno-leading-underscore, change the way C symbols are represented in the object file. One use is to help link with legacy assembly code. Warning: the -fleading-underscore switch causes GCC to generate code that is not binary compatible with code generated without that switch. Use it to conform to a non-default application binary interface. Not all targets provide complete support for this switch.
    -ftls-model=model Alter the thread-local storage model to be used. The model argument should be one of "global-dynamic", "local-dynamic", "initial-exec" or "local-exec". The default without -fpic is "initial-exec"; with -fpic the default is "global-dynamic".
    Set the default ELF image symbol visibility to the specified option---all symbols will be marked with this unless overridden within the code. Using this feature can very substantially improve linking and load times of shared object libraries, produce more optimized code, provide near- perfect API export and prevent symbol clashes. It is strongly recommended that you use this in any shared objects you distribute.

    Despite the nomenclature, "default" always means public ie; available to be linked against from outside the shared object. "protected" and "internal" are pretty useless in real-world usage so the only other commonly used option will be "hidden". The default if -fvisibility isn't specified is "default", i.e., make every symbol public---this causes the same behavior as previous versions of GCC.

    A good explanation of the benefits offered by ensuring ELF symbols have the correct visibility is given by How To Write Shared Libraries by Ulrich Drepper (which can be found at )---however a superior solution made possible by this option to marking things hidden when the default is public is to make the default hidden and mark things public. This is the norm with DLL's on Windows and with -fvisibility=hidden and "__attribute__ ((visibility("default")))" instead of "__declspec(dllexport)" you get almost identical semantics with identical syntax. This is a great boon to those working with cross-platform projects.

    For those adding visibility support to existing code, you may find #pragma GCC visibility of use. This works by you enclosing the declarations you wish to set visibility for with (for example) #pragma GCC visibility push(hidden) and #pragma GCC visibility pop. These can be nested up to sixteen times. Bear in mind that symbol visibility should be viewed as part of the API interface contract and thus all new code should always specify visibility when it is not the default ie; declarations only for use within the local DSO should always be marked explicitly as hidden as so to avoid PLT indirection overheads---making this abundantly clear also aids readability and self- documentation of the code. Note that due to ISO C++ specification requirements, operator new and operator delete must always be of default visibility.

    Be aware that headers from outside your project, in particular system headers and headers from any other library you use, may not be expecting to be compiled with visibility other than the default. You may need to explicitly say #pragma GCC visibility push(default) before including any such headers.

    An overview of these techniques, their benefits and how to use them is at


    Some work by specifying directories or prefixes to use when searching for various kinds of files.
    Some specify other aspects of the compilation environment.

    Specify places to search using options such as -B, -I and -L. which take precedence over specified in environment variables, which take precedence over those specified by the configuration

    control the way GCC uses localization . if it has been configured . A typical value is en_GB.UTF-8 for English in the United Kingdom encoded in UTF-8.

    $LC_CTYPE specifies character classification. determines the character boundaries in a string; this is needed for some multibyte encodings that contain quote and escape characters that would otherwise be interpreted as a string end or escape.

    $LC_MESSAGES language for diagnostic messages. $LC_ALL overrides $LC_CTYPE and $LC_MESSAGES; otherwise, $LC_CTYPE and $LC_MESSAGES default to the value of $LANG

    $LANG character set to be used when character literals, string literals and comments are parsed . When the compiler is configured to allow multibyte characters, the following values are recognized:
    C-JIS Recognize JIS characters.
    C-SJIS Recognize SJIS characters.
    C-EUCJP Recognize EUCJP characters.

    If $LANG is not defined the compiler will use mblen and mbtowc from the default locale to recognize and translate multibyte characters.

    $TMPDIR directory is used for temporary files for the output of one stage of compilation used as input to the next stage:
    $GCC_EXEC_PREFIX Prefix for the subprograms executed by the compiler. No slash is added
    Default a prefix is based on the pathname it was invoked with. The default is prefix/lib/gcc/ where prefix defined in the configure script.

    prefixes with -B take precedence over this prefix.

    This prefix is used with files such as crt0.o for linking. prefix is used in finding the directories to search for headers. For each of the standard directories whose name normally begins with /usr/local/lib/gcc (more precisely, with the value of GCC_INCLUDE_DIR), GCC replaces that beginning with the specified prefix to produce an alternate directory name. Thus, with -Bfoo/ , GCC searchs foo/bar where it would search /usr/local/lib/bar.
    These alternate directories are searched first; the standard directories come next.

    $COMPILER_PATH colon-separated list of directories, GCC the directories specified when searching for subprograms, if it can't find the subprograms using GCC_EXEC_PREFIX.
    $LIBRARY_PATH a colon-separated list of directories, As a native compiler, GCC tries these directories when searching for special linker files,
    If it can't find them using $GCC_EXEC_PREFIX. Linking uses these directories when searching for libraries with -l after searching those with -L.
    $CPATH a list directories separated by a "PATH_SEPARATOR", in which to look for header files. For MS-based targets it is a semicolon, and for other targets a colon. Directories from $CPATH as used as if specified with -I, after paths on the command line.

    a list of directories to be searched as if specified with -isystem, after paths given with -isystem on the command line. In all these variables, an empty element instructs the compiler to search its current working directory.
    Empty elements can appear at the beginning or end of a path. For instance, if $CPATH is :/special/include it is the same as -I. -I/special/include.
    $DEPENDENCIES_OUTPUT how to output dependencies for Make based on the non-system header files processed by the compiler.
    System header files are ignored in the dependency output.

    $DEPENDENCIES_OUTPUT can be a file, the Make rules are written to that file, using the target name from the source file name. Or the value can have the form file target, in which case the rules are written to file file using target as the target name. This is equivalent to combining the options -MM and -MF, with an optional -MT switch .

    $SUNPRO_DEPENDENCIES As with $DEPENDENCIES_OUTPUT except that system header files are not ignored, so it implies -M rather than -MM. The dependence on the main input file is omitted.


    1. On some systems, gcc -shared builds supplementary stub code for constructors to work. On multi-libbed systems, gcc -shared must select the correct support libraries to link against. Failing to supply the correct flags may lead to subtle defects.


    gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1) and the Info entries for gcc, cpp, as, ld, binutils and gdb.
    As of 07/21/11
     gcc -v
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
    gcc --help
    Usage: i686-apple-darwin10-gcc-4.2.1 [options] file...
      -pass-exit-codes         Exit with highest error code from a phase
      --help                   Display this information
      --target-help            Display target specific command line options
      (Use '-v --help' to display command line options of sub-processes)
      -dumpspecs               Display all of the built in spec strings
      -dumpversion             Display the version of the compiler
      -dumpmachine             Display the compiler's target processor
      -print-search-dirs       Display the directories in the compiler's search path
      -print-libgcc-file-name  Display the name of the compiler's companion library
      -print-file-name=<lib>   Display the full path to library <lib>
      -print-prog-name=<prog>  Display the full path to compiler component <prog>
      -print-multi-directory   Display the root directory for versions of libgcc
      -print-multi-lib         Display the mapping between command line options and multiple library search directories
      -print-multi-os-directory Display the relative path to OS libraries
      -Wa,<options>            Pass comma-separated <options> on to the assembler
      -Wp,<options>            Pass comma-separated <options> on to the preprocessor
      -Wl,<options>            Pass comma-separated <options> on to the linker
      -Xassembler <arg>        Pass <arg> on to the assembler
      -Xpreprocessor <arg>     Pass <arg> on to the preprocessor
      -Xlinker <arg>           Pass <arg> on to the linker   see also -Wl,-Map=$(
      -combine                 Pass multiple source files to compiler at once
      -save-temps              Do not delete intermediate files
      -pipe                    Use pipes rather than intermediate files
      -time                    Time the execution of each subprocess
      -specs=<file>            Override built-in specs with the contents of <file>
      -std=<standard>          Assume that the input sources are for <standard>
      --sysroot=<directory>    Use <directory> as the root directory for headers and libraries
      -B <directory>           Add <directory> to the compiler's search paths
      -b <machine>             Run gcc for target <machine>, if installed
      -V <version>             Run gcc version number <version>, if installed
      -v                       Display the programs invoked by the compiler
      -###                     Like -v but options quoted and commands not executed
      -E                       Preprocess only; do not compile, assemble or link
      -S                       Compile only; do not assemble or link
      -c                       Compile and assemble, but do not link
      -o <file>                Place the output into <file>
      -x <language>            Specify the language of the following input files
                               Permissible languages include: c c++ assembler none
                               'none' means revert to the default behavior of
                               guessing the language based on the file's extension
    Options starting with -g, -f, -m, -O, -W, or --param are automatically passed on to the various sub-processes invoked by i686-apple-darwin10-gcc-4.2.1. In order to pass other options on to these processes the -Wletter> options must be used. __func__ is a VARIABLE with a value , not a macro.