gcc幫助手冊01部分(1~139行)
gcc是每個從事C語言,必備的核心指令之一,第1部分幫助手冊如下。
GCC(1) GNU GCC(1)
NAME
gcc - GNU project C and C++ compiler
SYNOPSIS
gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-Wpedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] [@file] infile...
Only the most useful options are listed here; see below for the remainder. g++ accepts mostly the same options
as gcc.
DESCRIPTION
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options"
allow you to stop this process at an intermediate stage. For example, the -c option says not to run the
linker. Then the output consists of object files output by the assembler.
Other options are passed on to one or more stages of processing. Some options control the preprocessor and
others the compiler itself. Yet other options control the assembler and linker; most of these are not
documented here, since you rarely need to use any of them.
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.
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 specific version of GCC. When you compile C++ programs, you should invoke GCC as
g++ instead.
The gcc program accepts options and file names as operands. Many options have multi-letter names; therefore
multiple single-letter options may not be grouped: -dv is very different from -d -v.
You can mix options and other arguments. For the most part, the order you use doesn't matter. Order does
matter when you use several options of the same kind; for example, if you specify -L more than once, the
directories are searched in the order specified. Also, the placement of the -l option is significant.
Many options have long names starting with -f or with -W---for example, -fmove-loop-invariants, -Wformat and so
on. Most of these have both positive and negative forms; the negative form of -ffoo is -fno-foo. This manual
documents only one of these two forms, whichever one is not the default.
Some options take one or more arguments typically separated either by a space or by the equals sign (=) from
the option name. Unless documented otherwise, an argument can be either numeric or a string. Numeric
arguments must typically be small unsigned decimal or hexadecimal integers. Hexadecimal arguments must begin
with the 0x prefix. Arguments to options that specify a size threshold of some sort may be arbitrarily large
decimal or hexadecimal integers followed by a byte size suffix designating a multiple of bytes such as "kB" and
"KiB" for kilobyte and kibibyte, respectively, "MB" and "MiB" for megabyte and mebibyte, "GB" and "GiB" for
gigabyte and gigibyte, and so on. Such arguments are designated by byte-size in the following text. Refer to
the NIST, IEC, and other relevant national and international standards for the full listing and explanation of
the binary and decimal byte size prefixes.
OPTIONS
Option Summary
Here is a summary of all the options, grouped by type. Explanations are in the following sections.
Overall Options
-c -S -E -o file -dumpbase dumpbase -dumpbase-ext auxdropsuf -dumpdir dumppfx -x language -v -###
--help[=class[,...]] --target-help --version -pass-exit-codes -pipe -specs=file -wrapper @file
-ffile-prefix-map=old=new -fplugin=file -fplugin-arg-name=arg -fdump-ada-spec[-slim]
-fada-spec-parent=unit -fdump-go-spec=file
C Language Options
-ansi -std=standard -fgnu89-inline -fpermitted-flt-eval-methods=standard -aux-info filename
-fallow-parameterless-variadic-functions -fno-asm -fno-builtin -fno-builtin-function -fgimple -fhosted
-ffreestanding -fopenacc -fopenacc-dim=geom -fopenmp -fopenmp-simd -fms-extensions -fplan9-extensions
-fsso-struct=endianness -fallow-single-precision -fcond-mismatch -flax-vector-conversions
-fsigned-bitfields -fsigned-char -funsigned-bitfields -funsigned-char
C++ Language Options
-fabi-version=n -fno-access-control -faligned-new=n -fargs-in-order=n -fchar8_t -fcheck-new
-fconstexpr-depth=n -fconstexpr-cache-depth=n -fconstexpr-loop-limit=n -fconstexpr-ops-limit=n
-fno-elide-constructors -fno-enforce-eh-specs -fno-gnu-keywords -fno-implicit-templates
-fno-implicit-inline-templates -fno-implement-inlines -fmodule-header[=kind] -fmodule-only -fmodules-ts
-fmodule-implicit-inline -fno-module-lazy -fmodule-mapper=specification -fmodule-version-ignore
-fms-extensions -fnew-inheriting-ctors -fnew-ttp-matching -fno-nonansi-builtins -fnothrow-opt
-fno-operator-names -fno-optional-diags -fpermissive -fno-pretty-templates -fno-rtti -fsized-deallocation
-ftemplate-backtrace-limit=n -ftemplate-depth=n -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak
-nostdinc++ -fvisibility-inlines-hidden -fvisibility-ms-compat -fext-numeric-literals
-flang-info-include-translate[=header] -flang-info-include-translate-not -flang-info-module-cmi[=module]
-stdlib=libstdc++,libc++ -Wabi-tag -Wcatch-value -Wcatch-value=n -Wno-class-conversion -Wclass-memaccess
-Wcomma-subscript -Wconditionally-supported -Wno-conversion-null -Wctad-maybe-unsupported
-Wctor-dtor-privacy -Wno-delete-incomplete -Wdelete-non-virtual-dtor -Wdeprecated-copy
-Wdeprecated-copy-dtor -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion -Weffc++
-Wno-exceptions -Wextra-semi -Wno-inaccessible-base -Wno-inherited-variadic-ctor -Wno-init-list-lifetime
-Winvalid-imported-macros -Wno-invalid-offsetof -Wno-literal-suffix -Wno-mismatched-new-delete
-Wmismatched-tags -Wmultiple-inheritance -Wnamespaces -Wnarrowing -Wnoexcept -Wnoexcept-type
-Wnon-virtual-dtor -Wpessimizing-move -Wno-placement-new -Wplacement-new=n -Wrange-loop-construct
-Wredundant-move -Wredundant-tags -Wreorder -Wregister -Wstrict-null-sentinel -Wno-subobject-linkage
-Wtemplates -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions
-Wsign-promo -Wsized-deallocation -Wsuggest-final-methods -Wsuggest-final-types -Wsuggest-override
-Wno-terminate -Wuseless-cast -Wno-vexing-parse -Wvirtual-inheritance -Wno-virtual-move-assign
-Wvolatile -Wzero-as-null-pointer-constant
Objective-C and Objective-C++ Language Options
-fconstant-string-class=class-name -fgnu-runtime -fnext-runtime -fno-nil-receivers -fobjc-abi-version=n
-fobjc-call-cxx-cdtors -fobjc-direct-dispatch -fobjc-exceptions -fobjc-gc -fobjc-nilcheck -fobjc-std=objc1
-fno-local-ivars -fivar-visibility=[public|protected|private|package] -freplace-objc-classes -fzero-link
-gen-decls -Wassign-intercept -Wno-property-assign-default -Wno-protocol -Wobjc-root-class -Wselector
-Wstrict-selector-match -Wundeclared-selector
Diagnostic Message Formatting Options
-fmessage-length=n -fdiagnostics-plain-output -fdiagnostics-show-location=[once|every-line]
-fdiagnostics-color=[auto|never|always] -fdiagnostics-urls=[auto|never|always]
-fdiagnostics-format=[text|json] -fno-diagnostics-show-option -fno-diagnostics-show-caret
-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers -fno-diagnostics-show-cwe
-fdiagnostics-minimum-margin-width=width -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
-fdiagnostics-show-template-tree -fno-elide-type -fdiagnostics-path-format=[none|separate-events|inline-
events] -fdiagnostics-show-path-depths -fno-show-column -fdiagnostics-column-unit=[display|byte]
-fdiagnostics-column-origin=origin
Warning Options
-fsyntax-only -fmax-errors=n -Wpedantic -pedantic-errors -w -Wextra -Wall -Wabi=n -Waddress
-Wno-address-of-packed-member -Waggregate-return -Walloc-size-larger-than=byte-size -Walloc-zero -Walloca
-Walloca-larger-than=byte-size -Wno-aggressive-loop-optimizations -Warith-conversion -Warray-bounds
-Warray-bounds=n -Wno-attributes -Wattribute-alias=n -Wno-attribute-alias -Wno-attribute-warning
-Wbool-compare -Wbool-operation -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined
-Wc90-c99-compat -Wc99-c11-compat -Wc11-c2x-compat -Wc++-compat -Wc++11-compat -Wc++14-compat
-Wc++17-compat -Wc++20-compat -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
-Wchar-subscripts -Wclobbered -Wcomment -Wconversion -Wno-coverage-mismatch -Wno-cpp -Wdangling-else
-Wdate-time -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init -Wdisabled-optimization
-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers -Wno-div-by-zero -Wdouble-promotion
-Wduplicated-branches -Wduplicated-cond -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors -Wfloat-conversion -Wfloat-equal -Wformat
-Wformat=2 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral -Wformat-overflow=n
-Wformat-security -Wformat-signedness -Wformat-truncation=n -Wformat-y2k -Wframe-address
-Wframe-larger-than=byte-size -Wno-free-nonheap-object -Wno-if-not-aligned -Wno-ignored-attributes
-Wignored-qualifiers -Wno-incompatible-pointer-types -Wimplicit -Wimplicit-fallthrough
-Wimplicit-fallthrough=n -Wno-implicit-function-declaration -Wno-implicit-int -Winit-self -Winline
-Wno-int-conversion -Wint-in-bool-context -Wno-int-to-pointer-cast -Wno-invalid-memory-model
-Winvalid-pch -Wjump-misses-init -Wlarger-than=byte-size -Wlogical-not-parentheses -Wlogical-op
-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized -Wmemset-elt-size
-Wmemset-transposed-args -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
-Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn
-Wno-missing-profile -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
-Wnormalized=[none|id|nfc|nfkc] -Wnull-dereference -Wno-odr -Wopenmp-simd -Wno-overflow
-Woverlength-strings -Wno-override-init-side-effects -Wpacked -Wno-packed-bitfield-compat
-Wpacked-not-aligned -Wpadded -Wparentheses -Wno-pedantic-ms-format -Wpointer-arith -Wno-pointer-compare
-Wno-pointer-to-int-cast -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls -Wrestrict
-Wno-return-local-addr -Wreturn-type -Wno-scalar-storage-order -Wsequence-point -Wshadow -Wshadow=global
-Wshadow=local -Wshadow=compatible-local -Wno-shadow-ivar -Wno-shift-count-negative
-Wno-shift-count-overflow -Wshift-negative-value -Wno-shift-overflow -Wshift-overflow=n -Wsign-compare
-Wsign-conversion -Wno-sizeof-array-argument -Wsizeof-array-div -Wsizeof-pointer-div
-Wsizeof-pointer-memaccess -Wstack-protector -Wstack-usage=byte-size -Wstrict-aliasing
-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=n -Wstring-compare -Wno-stringop-overflow
-Wno-stringop-overread -Wno-stringop-truncation -Wsuggest-attribute=[pure|const|noreturn|format|malloc]
-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum -Wno-switch-outside-range
-Wno-switch-unreachable -Wsync-nand -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
-Wtsan -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunsuffixed-float-constants -Wunused
-Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable -Wunused-const-variable=n
-Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros -Wunused-parameter
-Wno-unused-result -Wunused-value -Wunused-variable -Wno-varargs -Wvariadic-macros
-Wvector-operation-performance -Wvla -Wvla-larger-than=byte-size -Wno-vla-larger-than
-Wvolatile-register-var -Wwrite-strings -Wzero-length-bounds