# Use the compilers
The LLVM compilers translate C and C++ programs into Arm processor
code.
C and C++ programs are stored in source files, which are text files
created with a text editor. Arm processor code is stored in object
files, which are executable binary files.
## Start the compilers
To start the C compiler from the command line, enter:
>
>
> **clang [***options*…**]** *input\_files*…
To start the C++ compiler from the command line, enter:
>
>
> **clang++ [***options*…**]** *input\_files*…
The compilers accept one or more input files on the command line.
Input files can be C/C++ source files or object files. For example:
`clang hello.c mylib.c`
Command switches are used to control various
[compiler options](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#compiler-options). A switch consists of a dash
character (-) followed by a switch name and optional parameter.
Switches are case-sensitive and must be separated by at least one
space. For example:
>
>
> **clang hello.c -o hello**
To list the available command options, use the –help option:
>
>
> **clang –help clang++ –help**
This option causes the compiler to display the command line syntax,
followed by a list of the available command options. clang is the
name of the front-end driver for the LLVM compiler framework.
## Input and output files
The LLVM compilers preprocess and compile one or more source files
into object files. The compilers then invoke the linker to combine
the object files into an executable file.
Following are the input file types and the tool that processes files
of each type. The compilers use the filename extension to determine
how to process the file.
| **Extension** | **Description** | **Tool** |
| --- | --- | --- |
| .c | C source file | C compiler |
| .i | C preprocessed file | |
| .h | C header file | |
| .cc
.cp
.cxx
.cpp
.CPP
.c++
.C | C++ source file | C++ compiler |
| .ii | C++ preprocessed file | |
| .h
.hh
.H | C++ header file | |
| .bc
.ll | LLVM intermediate representation
(IR) file | C/C++ compiler |
| .s
.S | Assembly source file | Assembler |
| Other | Binary object file | Linker |
All filename extensions are case-sensitive literal strings. Input
files with unrecognized extensions are treated as object files. For
more information on LLVM IR files, see
[llvm.org](http://llvm.org/).
The following table lists the output file types and the tools used to generate
each file type. [Compiler options](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#compiler-options) are used to specify
the output file type.
| File type | Default
file
name | Input files |
| --- | --- | --- |
| Executable file | a.out | The specified source files are
compiled and linked to a single
executable file. |
| Object file | file.o | Each specified source file is
compiled to a separate object file
(where file is the source filename). |
| Assembly source
file | file.s | Each specified source file is
compiled to a separate assembly
source file (where file is the source
filename). |
| Preprocessed
C/C++ source
file | stdout | The preprocessor output is written to
the standard output. |
## Compiler options
The LLVM compilers can be controlled by [command-line options](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#start-the-compilers).
Many of the GCC options are supported, along with options that are
LLVM-specific.
Many of the -f, -m, and -W` options can be written in two ways:
-f*<option>* to enable a binary option, or -fno-*<option>* to
disable the option.
-mllvm is not a standalone option, but rather a standard prefix that
appears in many LLVM-specific option names.
The following is a quick reference of the options.
- [Display](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-display)
-help
-v
Copy to clipboard
- [Compilation](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-compilation)
-###
-c
-cc1
-ccc-print-phases
-E
-no-canonical-prefixes
-pipe
-o
-S
-Wa,[,...]
-Wl,[,...]
-Wp,[,...]
-x
-Xclang
Copy to clipboard
- [C dialect](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-c-dialect)
-ansi
-fblocks
-fgnu-runtime
-fgnu89-inline
-fno-asm
-fsigned-bitfields
-fsigned-char
-funsigned-char
-no-integrated-cpp
-std=(c89|gnu89|c99|gnu99|c11|gnu11)
-traditional
-Wpointer-sign
Copy to clipboard
- [C++ dialect](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-cpp-dialect)
-cxx-isystem
-ffor-scope | -fno-for-scope
-fno-gnu-keywords
-ftemplate-depth-n
-fvisibility-inlines-hidden
-fuse-cxa-atexit
-nobuiltininc
-nostdinc++
-std=(c++98|gnu++98|c++11|gnu++11|c++14|gnu++14|c++17|gnu++17)
-Wc++0x-compat
-Wno-deprecated
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wreorder
Copy to clipboard
- [Warning and error messages](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-warning-and-error-messages)
c++98|c++11|c++14|c++17-compat-pedantic cast-calling-convention
comma
constant-conversion expansion-to-defined
-ferror-limit=
-ferror-warn float-overflow-conversion
float-zero-conversion
-ftemplate-backtrace-limit=
-fsyntax-only incompatible-sysroot nonportable-include-path
nonportable-system-include-path null-dereference
openmp-target
-pedantic | -Wpedantic pedantic-core-features
-pedantic-errors
-Qunused-arguments
shadow-field-in-constructor-modified shadow-field-in-constructor
undefined-func-template
undefined-var-template unguarded-availability unknown-argument
unsupported-cb
varargs
-w
-W
-Wno-
-Wall
-Warray-bounds
-Wcast-align
-Wchar-subscripts
-Wcomment
-Wconversion
-Wdeclaration-after-statement
-Wno-deprecated-declarations
-Wempty-body
-Wendif-labels
-Werror
-Werror=
-Wno-error=
-Werror-implicit-function-declaration
-Weverything
-Wextra
-Wfloat-equal
-Wformat
-Wformat=2
-Wformat-nonliteral
-Wformat-security
-Wignored-qualifiers
-Wimplicit
-Wimplicit-function-declaration
-Wimplicit-int
-Wno-format-extra-args
-Wno-invalid-offsetof
-Wlong-long
-Wmain
-Wmissing-braces
-Wmissing-declarations
-Wmissing-noreturn
-Wmissing-prototypes
-Wno-multichar
-Wnonnull
-Wpacked
-Wpadded
-Wparentheses
-Wpedantic
-Wpointer-arith
-Wreturn-type
-Wshadow
-Wsign-compare
-Wswitch | -Wswitch-enum
-Wsystem-headers
-Wtrigraphs
-Wundef
-Wuninitialized
-Wunknown-pragmas
-Wunreachable-code
-Wunused
-Wunused-function
-Wunused-label
-Wunused-parameter
-Wunused-value
-Wunused-variable
-Wno-vectorizer-no-neon
-Wwrite-strings
Copy to clipboard
- [Debugging](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-debugging)
-dumpmachine
-dumpversion
-feliminate-unused-debug-symbols
-time | -ftime-report
-g[]
-gline-tables-only
-print-diagnostic-categories
-print-file-name=
-print-libgcc-file-
-print-multi-directory
-print-multi-lib
-print-multi-os-directory
-print-prog-name=
-print-search-dirs
-save-temps
Copy to clipboard
- [Diagnostic format](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-diagnostic-format)
-fcaret-diagnostics | -fno-caret-diagnostics
-fdiagnostics-show-option | -fno-diagnostics-show-option
-fdiagnostics-show-category=(none|id|name)
-fdiagnostics-print-source-range-info
-fno-diagnostics-print-source-range-info
-fdiagnostics-parseable-fixits
-fdiagnostics-show-template-tree
-fmessage-length=
Copy to clipboard
- [Individual warning groups](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-individual-warning-groups)
-Wextra-tokens
-Wambiguous-member-template
-Wbind-to-temporary-copy
Copy to clipboard
- [Compiler crash diagnostics](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-compiler-crash-diagnostics)
-fno-crash-diagnostics
Copy to clipboard
- [Linker](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-linker)
-fuse-ld=(gold|bfd|qcld)
Copy to clipboard
- [Preprocessor](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-preprocessor)
-A pred=
-A -pred=
-ansi
-C
-CC
-d(DMNU)
-D | -D =
-fexec-charset=charset
-finput-charset=charset
-fpch-deps
-fpreprocessed
-fstrict-overflow
-ftabstop=
-fwide-exec-charset=charset
-fworking-directory
-H
--help
-I
-I-
-include
-isystem
-isystem-prefix
-ino-system-prefix
-M
-MD
-MF
-MG
-MM
-MMD
-MP
-MQ
-MT
-nostdinc
-nostdinc++
-o
-P
-remap
--target-help
-traditional-cpp
-trigraphs
-U
-v
-version
--version
-w
-Wall
-Wcomment | -Wcomments
-Wendif-labels
-Werror
-Wimport
-Wsystem-headers
-Wtrigraphs
-Wundef
-Wunused-macros
Copy to clipboard
- [Assembling](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-assembling)
-fintegrated-as | -fno-integrated-as
-Xassembler
Copy to clipboard
- [Linking](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-linking)
object_file_name
-c
-dynamic
-E
-l
-moslib=
-nodefaultlibs
-nostartfiles
-nostdlib
-pie
-s
-S
-shared
-shared-libgcc
-static
-static-libgcc
-symbolic
-u
-Xlinker
Copy to clipboard
- [Directory search](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-directory-search)
-B
-F
--gcc-toolchain=
-I
-I-
-L
Copy to clipboard
- [Processor version](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-processor-version)
-target
-march=
-mcpu=
-mfpu=
-mfloat-abi=(soft|softfp|hard)
Copy to clipboard
- [Code generation](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-code-generation)
-fchar-array-precise-tbaa | -fno-char-array-precise-tbaa
-femit-all-data
-femit-all-decls
-ffp-contract=(fast|on|off)
-finstrument-functions
-fmerge-functions | -fno-merge-functions
-fno-exceptions
-fpic
-fPIC
-fpie | -fPIE
-fsanitize=address | -fno-sanitize=address
-fsanitize=memory | -fno-sanitize=memory
-fsanitize=[<,event>...] | -fno-sanitize=[<,event>...]
-fsanitize=integer
-fsanitize=undefined
-fsanitize-blacklist= | -fno-sanitize-blacklist
-fsanitize-memory-track-origins[=]
-fsanitize-messages | -fno-sanitize-messages
-fsanitize-opt-size | -fno-sanitize-opt-size
-fsanitize-source-loc | -fno-sanitize-source-loc
-fsanitize-use-embedded-rt
-fshort-enums | -fno-short-enums
-fshort-wchar | -fno-short-wchar
-ftrap-function=
-ftrapv
-ftrapv-handler=
-funwind-tables
-fverbose-asm
-fvisibility=[default|internal|hidden|protected]
-fwrapv
-mhwdiv=(arm|thumb|arm,thumb|none)
-mllvm -aarch64-disable-abs-reloc
-mllvm -aggressive-jt
-mllvm -arm-expand-memcpy-runtime
-mllvm -arm-memset-size-threshold
-mllvm -arm-memset-size-threshold-zeroval
-mllvm -arm-opt-memcpy
-mllvm -disable-thumb-scale-addressing
-mllvm -emit-cp-at-end
-mllvm -enable-android-compat
-mllvm -enable-arm-addressing-opt
-mllvm -enable-arm-peephole
-mllvm -enable-arm-zext-opt
-mllvm -enable-print-fp-zero-alias
-mllvm -enable-round-robin-RA
-mllvm -enable-select-to-intrinsics
-mllvm -favor-r0-7
-mllvm -force-div-attr
-mllvm -prefetch-locality-policy=(L1|L2|L3|stream)
-mrestrict-it | -mno-restrict-it
Copy to clipboard
- [Vectorization](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-vectorization)
-ftree-vectorize
-fvectorize-loops
-fvectorize-loops-debug
-fprefetch-loop-arrays[=] | -fno-prefetch-loop-arrays
Copy to clipboard
- [Parallelization](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-parallelization)
-fparallel
Copy to clipboard
- [Optimization](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-optimization)
-O0
-O | -O1
-O2
-O3
-O4
-Ofast
-Os
-Osize
-Oz
Copy to clipboard
- [Specific optimizations](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-specific-optimizations)
-faggressive-unroll
-fdata-sections
-ffp-contract=[off|on|fast]
-ffunction-sections
-finline
-finline-functions
-floop-pragma
-fno-zero-initialized-in-bss
-fnomerge-all-constants
-fomit-frame-pointer
-foptimize-sibling-calls
-fstack-protector
-fstack-protector-all
-fstack-protector-strong
-fstrict-aliasing
-funit-at-a-time
-funroll-all-loops
-funroll-loops
-maggressive-size-opts
--param ssp-buffer-size=
Copy to clipboard
- [Math optimization](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-math-optimizations)
-fassociative-math
-ffast-math
-ffinite-math-only
-fno-math-errno
-freciprocal-math
-fno-signed-zeros
-fno-trapping-math
-funsafe-math-optimizations
Copy to clipboard
- [Link-time optimization (compiler and linker)](https://docs.qualcomm.com/doc/80-VB419-99/topic/code_optimization.html#sec-link-time-optimization)
-flto
Copy to clipboard
- [Profile-guided optimization](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-profile-guided-optimizations)
-fprofile-instr-generate[=]
-fprofile-instr-use=
-fprofile-sample-use=
Copy to clipboard
- [Optimization reports](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-use-compiler-optimization-reports)
-fopt-reporter=(vectorizer|parallelizer|all)
-polly-max-pointer-aliasing-checks
-Rpass=loop-opt
-Rpass-missed=loop-opt
Copy to clipboard
- [Compiler security](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-compiler-security)
--analyze
-analyzer-checker=
-analyzer-checker-help
-analyzer-disable-checker=
--analyzer-output html
--analyzer-Werror
--compile-and-analyze
--compile-and-analyze-high
--compile-and-analyze-medium
-ffcfi
-fno-fcfi
Copy to clipboard
### Display
- **-help**
- Displays compiler command and option summary.
- **-v**
- Displays compiler release version.
### Compilation
- **-###**
- Prints commands used to perform the compilation.
- **-c**
- Compiles the source file, but does not link it.
- **-cc1**
- Bypasses the compiler driver and go directly to LLVM.
- **-ccc-print-phases**
- Prints the compilation stages as they occur.
- **-E**
- Preprocesses the source file only; does not compile it.
- **-no-canonical-prefixes**
- When processing a pathname:
- Does not expand any symbolic links
- Does not resolve any references to /./ or /../
- Does not make relative prefixes absolute
- **-pipe**
- Communicates between compiler stages using pipes not temporary files.
- **-o** *file*
- Specify the name of the compiler output file.
- **-S**
- Compiles the source file, but does not assemble it.
- **-Wa,<arg>[,<arg>…]**
- Passes the specified arguments to the assembler.
- **-Wl,<arg>[,<arg>…]**
- Passes the specified arguments to the linker.
- **-Wp,<arg>[,<arg>…]**
- Passes the specified arguments to the preprocessor.
- **-x <language>**
- Specifies the language of the subsequent source files specified on the command line.
- **-Xclang <arg>**
- Passes the specified argument to the compiler.
### C dialect
- **-ansi**
- For C, supports ISO C90.
For C++, removes conflicting GNU extensions.
- **-fblocks**
- Enables the Apple blocks extension.
- **-fgnu-runtime**
- Generates output compatible with the standard GNU Objective-C runtime.
- **-fgnu89-inline**
- Uses the gnu89 inline semantics.
- **-fno-asm**
- Does not recognize asm, inline, or typeof as keywords.
- **-fsigned-bitfields**
- Defines bit fields as signed.
- **-fsigned-char**
- Defines the char type as signed.
- **-funsigned-char**
- Defines the char type as unsigned.
- **-no-integrated-cpp**
- Compiles using separate preprocessing and compilation stages.
- **-std=(c89|gnu89|c99|gnu99|c11|gnu11)**
- LLVM C language mode. The default setting is gnu11.
- **-traditional**
- Supports pre-standard C language.
- **-Wpointer-sign**
- Flag pointers when assigned or passed values with a differing sign.
### C++ dialect
- **-cxx-isystem <dir>**
- Adds a specified directory to C++ SYSTEM include search path.
- **-ffor-scope** | **-fno-for-scope**
- Controls whether the scope of a variable declared in a for statement
is limited to the statement or to the scope enclosing the statement.
- **-fno-gnu-keywords**
- Disables recognizing typeof as a keyword.
- **-ftemplate-depth-n**
- Specifies the maximum instantiation depth of a template class.
- **-fvisibility-inlines-hidden**
- Specifies the default visibility for inline C++ member functions.
- **-fuse-cxa-atexit**
- Registers destructors with function cxa\_atexit (instead of atexit).
This option applies only to objects that have static storage
duration.
- **-nobuiltininc**
- Disables built-in #include directories.
- **-nostdinc++**
- Disables standard #include directories for the C++ standard library.
- **-std=(c++98|gnu++98|c++11|gnu++11|c++14|gnu++14|c++17|gnu++17)**
- LLVM C++ language mode. The default setting is gnu++14.
- **-Wc++0x-compat**
- Generates warnings for C++ constructs with different semantics in ISO
C++ 1998 and ISO C++ 200x.
- **-Wno-deprecated**
- Does not generate warnings when deprecated features are used.
- **-Wnon-virtual-dtor**
- Generates a warning when a polymorphic class is declared with a
non-virtual destructor.
- **-Woverloaded-virtual**
- Generates a warning when a function hides virtual functions from a
base class.
- **-Wreorder**
- Generates a warning when member initializers do not appear in the
code in the required execution order.
### Warning and error messages
- **c++98|c++11|c++14|c++17-compat-pedantic**
- Hexadecimal floating literals are incompatible with C++ standards
before C++1z.
Warns if the compiled code uses experimental features added to
language standards more recent than C++17.
- **cast-calling-convention**
- Cast between incompatible %0 and %1 calling conventions. Calls
through this pointer might abort at runtime.
- **comma**
- Possible misuse of comma operator here.
- **constant-conversion**
- Implicit conversion from %2 to %3 changes the value from %0 to %1.
- **expansion-to-defined**
- Macro expansion producing defined has undefined behavior.
- **-ferror-limit=<n>**
- Stops emitting diagnostics after *n* errors have been produced. The
default setting is 20. Disable the error limit with -ferror-limit=0.
- **-ferror-warn <filename>**
- Converts the specified set of compiler warnings into errors.
The specified text file contains a list of warning names, with each
warning name separated by whitespace in the file.
Warning names are based on the switch names of the corresponding
compiler warning message options. For example, to convert the
warnings generated by
`-Wunused-variable`, use the warning name, unused-variable. You can
specify this option multiple times.
Note
You can integrate this option (and its associated file)
into a build system and use it to iteratively resolve the warning
messages generated by a project.
- **float-overflow-conversion**
- Implicit conversion of out of range value from %0 to %1 changes the
value from %2 to %3.
- **float-zero-conversion**
- Implicit conversion from %0 to %1 changes the non-zero value from %2
to %3.
- **-ftemplate-backtrace-limit=<n>**
- Only emits up to *n* template instantiation notes within the template
instantiation backtrace for a single warning or error. The default
setting is 10. Disable the limit with `-ftemplate-backtrace-limit=0`.
- **-fsyntax-only**
- Checks for syntax errors only.
- **incompatible-sysroot**
- Uses sysroot for %0 but targets %1.
- **nonportable-include-path**
- Non-portable path to file %0. The specified path differs in case from
the filename on the disk.
- **nonportable-system-include-path**
- Non-portable path to file %0. The specified path differs in case from
the filename on the disk.
- **null-dereference**
- Binding dereferenced NULL pointer to reference has undefined behavior.
- **openmp-target**
- Declaration is not declared in any declare target region.
- **-pedantic** | **-Wpedantic**
- Generate all warnings required by the ISO C and ISO C++ standards.
- **pedantic-core-features**
- OpenCL extension %0 is a core feature or a supported optional core
feature; ignoring.
- **-pedantic-errors**
- Equivalent to -pedantic, but generate errors instead of warnings.
- **-Qunused-arguments**
- Does not generate warnings for unused driver arguments.
- **shadow-field-in-constructor-modified**
- Modifying constructor parameter %0 that shadows a field of %1.
- **shadow-field-in-constructor**
- Constructor parameter %0 shadows the field %1 of %2.
- **undefined-func-template**
- Instantiation of function %q0 is required, but no definition is available.
- **undefined-var-template**
- Instantiation of variable %q0 is required, but no definition is available.
- **unguarded-availability**
- Using \* case here; platform %0 is not accounted for.
- **unknown-argument**
- Unknown argument is ignored in clang-cl: %0.
- **unsupported-cb**
- Ignoring -mcompact-branches= option because the %0 architecture does not support it.
- **varargs**
- Passing an object that undergoes a default argument promotion to
va\_start has undefined behavior.
- **-w**
- Suppresses all warnings.
- **-W<foo>**
- Enables the diagnostic *foo*.
- **-Wno-<foo>**
- Disables the diagnostic *foo*.
- **-Wall**
- Enables all -W options.
- **-Warray-bounds**
- Generates a warning if array subscripts are out of bounds.
- **-Wcast-align**
- Generates a warning if a pointer cast increases the required
alignment of the target.
- **-Wchar-subscripts**
- Generates a warning if array subscript is type char.
- **-Wcomment**
- Generates a warning if a comment symbol appears inside a comment.
- **-Wconversion**
- Generates a warning if an implicit conversion might alter a value.
- **-Wdeclaration-after-statement**
- Generates a warning when a declaration appears in a block after a statement.
- **-Wno-deprecated-declarations**
- Does not generate warnings for functions, variables, or types
assigned the attribute deprecated.
- **-Wempty-body**
- Generates a warning if an if, else, or do while statement contains an
empty body.
- **-Wendif-labels**
- Generates a warning if an #else or #endif directive is followed by
text.
- **-Werror**
- Converts all warnings into errors.
- **-Werror=<foo>**
- Converts the diagnostic *foo* into an error.
- **-Wno-error=<foo>**
- Keeps the diagnostic *foo* as a warning, even if `-Werror` is used.
- **-Werror-implicit-function-declaration**
- Generates a warning or error if a function is used before being
declared.
- **-Weverything**
- Enables all warnings.
- **-Wextra**
- Enables selected warning options, and generate warnings for selected events.
- **-Wfloat-equal**
- Generates a warning if two floating-point values are compared for equality.
- **-Wformat**
- In calls to printf, scanf and other functions with format strings,
ensures that the arguments are compatible with the specified format
string.
- **-Wformat=2**
- Equivalent to specifying the following options:
- `-Wformat`
- `-Wformat-nonliteral`
- `-Wformat-security`
- `-Wformat-y2k`
- **-Wformat-nonliteral**
- Generates a warning if the format string is not a string literal,
except if the format arguments are passed through va\_list.
- **-Wformat-security**
- Generates a warning for format function calls that might cause
security risks.
- **-Wignored-qualifiers**
- Generates a warning if a return type has a qualifier (such as const).
- **-Wimplicit**
- Equivalent to -Wimplicit-int and -Wimplicit-function-declaration.
- **-Wimplicit-function-declaration**
- Generates a warning if a function is used before it is declared.
- **-Wimplicit-int**
- Generates a warning if a declaration does not specify a type.
- **-Wno-format-extra-args**
- Does not generate a warning for passing extra arguments to printf or scanf.
- **-Wno-invalid-offsetof**
- Does not generate a warning if a non-POD type is passed to the
offsetof macro.
- **-Wlong-long**
- Generates a warning if typelong long is used.
- **-Wmain**
- Generates a warning if the main() function has any suspicious
properties.
- **-Wmissing-braces**
- Generates a warning if an aggregate or union initializer is not
properly bracketed.
- **-Wmissing-declarations**
- Generates a warning if a global function is defined without being
first declared.
- **-Wmissing-noreturn**
- Generates a warning if a function does not include a return
statement.
- **-Wmissing-prototypes**
- Generates a warning if a global function is defined without a
prototype.
- **-Wno-multichar**
- Does not generate a warning if a multiple-character constant is used.
- **-Wnonnull**
- Generates a warning if a NULL pointer is passed to an argument that
is specified to require a non-NULL value (with the nonnull
attribute).
- **-Wpacked**
- Generates a warning if the memory layout of a structure is not
affected after the structure is specified with the packed attribute.
- **-Wpadded**
- Generates a warning if the memory layout of a structure includes
padding.
- **-Wparentheses**
- Generates a warning if the parentheses are omitted in certain cases.
- **-Wpedantic**
- See -pedantic.
- **-Wpointer-arith**
- Generates a warning if any code depends on the size of void or a
function type.
- **-Wreturn-type**
- Generates a warning if a function returns a type that defaults to
int, or a value is incompatible with the defined return type.
- **-Wshadow**
- Generates a warning if a local variable shadows another local
variable, global variable, or parameter; or if a built-in function
gets shadowed.
- **-Wsign-compare**
- Generates a warning in a signed/unsigned compare operation if the
result might be inaccurate due to the signed operand being converted
to unsigned.
- **-Wswitch** | **-Wswitch-enum**
- Generates a warning if a switch statement uses an enum type for the
index, and does not specify a case for every possible enumeration
value, or specifies a case with a value outside the enumeration
range.
- **-Wsystem-headers**
- Generates a warning for constructs declared in system header files.
- **-Wtrigraphs**
- Generates a warning if a trigraph forms an escaped newline in a
comment.
- **-Wundef**
- Generates a warning if an undefined non-macro identifier appears in
an #if directive.
- **-Wuninitialized**
- Generates a warning if referencing an uninitialized automatic variable.
- **-Wunknown-pragmas**
- Generates a warning if a #pragma directive is not recognized by the compiler.
- **-Wunreachable-code**
- Generates a warning if code will never be executed.
- **-Wunused**
- Specifies all of the -Wunused options.
- **-Wunused-function**
- Generates a warning if a static function is declared without being
defined or used.
Note
No warning is generated for functions declared or defined
in header files.
- **-Wunused-label**
- Generates a warning if a label is declared without being used.
- **-Wunused-parameter**
- Generates a warning if a function argument is not used in its function.
- **-Wunused-value**
- Generates a warning if the value of a statement is not subsequently used.
- **-Wunused-variable**
- Generates a warning if a local or non-constant static variable is not
used in its function.
- **-Wno-vectorizer-no-neon**
- Does not generate the warning, Vectorization flags ignored because
armv7/armv8 and neon not set.
Vectorization requires an Armvv7 or Armvv8 target, and the NEON
feature must be enabled. If the vectorization options are used
without these required options, a warning is normally generated and
the vectorization options are ignored.
- **-Wwrite-strings**
- For C, assigns string constants the type const char[*length*] to
ensure that a warning is generated if the string address gets copied
to a non-const char \* pointer.
For C++, generates a warning that states a string constant is being
converted to char \*.
#### Warning—Argument unused during compilation: -mfpu=%0
Clang generates a warning when setting -mfpu in addition to
specifying AArch64. To avoid this warning, do not specify the -mfpu
option when specifying AArch64.
#### LLVM 4.0 release
**Table 4-3 LLVM 4.0 release: new warnings**
| **Category** | **Description** |
| --- | --- |
| -Wunused-command-line-argument | -fdiagnostics-show-hotness argument
requires profile-guided optimization
information. |
| -Wslash-u-filename | /UA treated as the /U option. |
| -Wunable-to-open-stats-file | Unable to open statistics output file
A: B. |
| -Wprivate-module | Top-level module A in a private
module map; expected a submodule of
B. |
| -Wempty-decomposition | ISO C++1z does not allow a
decomposition group to be empty. |
| -Wc++1z-extensions | Use of multiple declarators in a
single using declaration is a C++1z
extension. |
| -Wc++98-c++11-c++14-compat | Initialization statements are
incompatible with C++ standards
before C++1z. |
| -Wignored-pragma-intrinsic | A is not a recognized built-in
intrinsic; consider including
<intrin.h> to access non-built-in
intrinsics. |
| -Wignored-pragmas | Ignored. Expected *enable*,
*disable*, *begin*, or *end*. |
| -Wmax-unsigned-zero | Call to function without interrupt
attribute could clobber VFP registers
of the interruptee. |
| -Wextra | Call to function without interrupt
attribute could clobber VFP registers
of the interruptee. |
| -Wunused-lambda-capture | Variable explicitly captured by a
lambda is not used in the body of the
lambda. |
| -Wshadow-uncaptured-local | Declaration shadows a local variable. |
| -Wdynamic-exception-spec | ISO C++1z does not allow dynamic
exception specifications. |
| -Wc++1z-compat | Mangled name of A will change in
C++17 due to non- throwing exception
specification in function signature. |
| -Wreturn-type | Control might reach end of non-void
coroutine. |
| -Wmain | Boolean literal returned from *main.* |
| -Wincompatible-exception-spec | Exception specifications of return
type differ. |
| -Winconsistent-missing-
destructor-override | A overrides a destructor but is not
marked as *override.* |
| -Walloca-with-align-alignof | Second argument to
builtin\_alloca\_with\_align is supposed
to be in bits. |
| -Wsigned-enum-bitfield | Enums in the Microsoft ABI are signed
integers by default. Consider giving
the enum A an unsigned underlying
type to make this code portable. |
| -Wunguarded-availability | A is only available on B, C, or
newer. |
| -Win
valid-partial-specialization | Class/variable template partial
specialization is not more
specialized than the primary
template. |
| -Wstrict-prototypes | Function declaration is not a
prototype. |
| -Wblock-capture-autoreleasing | Block captures an auto-releasing
out-parameter, which might result in
use-after-free bugs. |
| -Waddress-of-packed-member | Taking address of packed member A of
class or structure B might result in
an unaligned pointer value. |
| -Wambiguous-delete | Multiple suitable A functions for B;
no *operator delete* function will be
invoked if initialization throws an
exception. |
| -Win
compatible-function-pointer-
types | Incompatible function pointer types
used. |
| -Wformat | Using A format specifier annotation
outside of os\_log()/os\_trace(). |
| -Wspir-compat | Sampler initializer has invalid A
bits. |
| -Wnullability
-completeness-on-
arrays | Array parameter is missing a NULL
type specifier (\_Nonnull,
\_Nullable, or \_Null\_unspecified). |
| -Wgcc-compat | final is a GNU extension. Consider
using C++11 final. |
#### LLVM 6.0 release
The following warning flags are new for LLVM 6.0:
- -Wbinary-literal
- -Wbinding-in-condition
- -Wbitfield-enum-conversion
- -Wc++17-compat
- -Wc++17-compat-mangling
- -Wc++17-compat-pedantic
- -Wc++17-extensions
- -Wc++1z-compat-mangling
- -Wc++2a-compat
- -Wc++2a-compat-pedantic
- -Wc++2a-extensions
- -Wc++98-c++11-compat-binary-literal
- -Wcoroutine-missing-unhandled-exception
- -Wcpp
- -Wenum-compare-switch
- -Wmissing-noescape
- -Wmsvc-not-found
- -Wnsconsumed-mismatch
- -Wnsreturns-mismatch
- -Wnull-pointer-arithmetic
- -Wobjc-flexible-array
- -Wobjc-messaging-id
- -Wout-of-scope-function
- -Wpragma-clang-attribute
- -Wpragma-pack
- -Wpragma-pack-suspicious-include
- -Wprofile-instr-missing
- -Wredundant-parens
- -Wtautological-constant-compare
- -Wtautological-unsigned-enum-zero-compare
- -Wtautological-unsigned-zero-compare
- -Wundefined-internal-type
- -Wunguarded-availability-new
- -Wunicode-homoglyph
- -Wunsupported-availability-guard
- -Wunused-template
- -Wzero-as-null-pointer-constant
For details, visit the llvm.org page:
[releases.llvm.org/6.0.0/tools/clang/docs/DiagnosticsReference.html](http://releases.llvm.org/6.0.0/tools/clang/docs/DiagnosticsReference.html)
#### LLVM 8.0 release
The following warning flags are new for LLVM 8.0:
- -Wargument-outside-range
- -Watimport-in-framework-header
- -Watomic-alignment
- -Watomic-implicit-seq-cst
- -Wc++98-compat-extra-semi
- -Wcast-qual-unrelated
- -Wdangling
- -Wdefaulted-function-deleted
- -Wdeprecated-this-capture
- -Wfixed-enum-extension
- -Wframework-include-private-from-public
- -Wfunction-multiversion
- -Wignored-pragma-optimize
- -Wimplicit-float-conversion
- -Wimplicit-int-conversion
- -Wincomplete-framework-module-declaration
- -Wmemset-transposed-args
- -Wnontrivial-memaccess
- -Wobjc-property-assign-on-object-type
- -Wordered-compare-function-pointers
- -Wquoted-include-in-framework-header
- -Wreturn-std-move
- -Wreturn-std-move-in-c++11
- -Wself-assign-overloaded
- -Wstdlibcxx-not-found
- -Wsuspicious-bzero
- -Wsuspicious-memaccess
- -Wunicode-zero-width
- -Wunsupported-target-opt
For details, visit the llvm.org page:
[https:\\clang.llvm.org/docs/DiagnosticsReference.html](https://clang.llvm.org/docs/DiagnosticsReference.html)
#### LLVM 10.0 release
The following warning flags are new for LLVM 10.0:
- -Walloca
- -Wavr-rtlib-linking-quirks
- -Wc++2a-designator
- -Wc99-designator
- -Wcall-to-pure-virtual-from-ctor-dtor
- -Wconcepts-ts-compat
- -Wctad-maybe-unsupported
- -Wctu
- -Wdangling-gsl
- -Wdarwin-sdk-settings
- -Wdelete-abstract-non-virtual-dtor
- -Wdelete-non-abstract-non-virtual-dtor
- -Wdeprecated-comma-subscript
- -Wempty-init-stmt
- -Wexport-unnamed
- -Wexport-using-directive
- -Wextra-semi-stmt
- -Wfinal-dtor-non-final-class
- -Wfortify-source
- -Wimplicit-fixed-point-conversion
- -Wimplicit-int-float-conversion
- -Wincomplete-setjmp-declaration
- -Winitializer-overrides
- -Wint-in-bool-context
- -Wmicrosoft-drectve-section
- -Wmisexpect
- -Wmissing-constinit
- -Wmodule-import
- -Wnoderef
- -Wobjc-bool-constant-conversion
- -Wobjc-boxing
- -Wobjc-signed-char-bool
- -Wobjc-signed-char-bool-implicit-float-conversion
- -Wobjc-signed-char-bool-implicit-int-conversion
- -Woverride-init
- -Wpointer-compare
- -Wpointer-integer-compare
- -Wpoison-system-directories
- -Wreorder-ctor
- -Wreorder-init-list
- -Wsigned-unsigned-wchar
- -Wsizeof-array-div
- -Wsizeof-pointer-div
- -Wstack-exhausted
- -Wtautological-objc-bool-compare
- -Wunderaligned-exception-object
- -Wxor-used-as-pow
For details, visit the llvm.org page:
[https://clang.llvm.org/docs/DiagnosticsReference.html](https://clang.llvm.org/docs/DiagnosticsReference.html)
#### LLVM 12.0 release
To review the warning flags that are new for LLVM 12.0, visit the
llvm.org page: [https://clang.llvm.org/docs/DiagnosticsReference.html](https://clang.llvm.org/docs/DiagnosticsReference.html)
### Debugging
- **-dumpmachine**
- Displays the target machine name.
- **-dumpversion**
- Displays the compiler version.
- **-feliminate-unused-debug-symbols**
- Generates debug information only for the symbols that are used.
(Debug information is generated in STABS format.)
- **-time** | **-ftime-report**
- Displays the elapsed time for each stage of the compilation.
- **-g[<level>]**
- Generates complete source-level debug information.
- **-gline-tables-only**
- Generates source-level debug information with line number tables only.
- **-print-diagnostic-categories**
- Displays mapping of diagnostic category names to category identifiers.
- **-print-file-name=<library>**
- Displays the full library path of the specified file.
- **-print-libgcc-file-name**
- Displays the library path for the libgcc.a file.
- **-print-multi-directory**
- Displays the directory names of the multiple libraries specified by
other compiler options in the current compilation.
- **-print-multi-lib**
- Displays the directory names of the multiple libraries paired with
the compiler options that specified the libraries in the current
compilation.
- **-print-multi-os-directory**
- Displays the relative path that is appended to the multi-lib search paths.
- **-print-prog-name=<program>**
- Displays the absolute path of the specified program.
- **-print-search-dirs**
- Displays the search paths used to locate libraries and programs
during compilation.
- **-save-temps**
- Saves the normally-temporary intermediate files generated during compilation.
### Diagnostic format
The LLVM compilers aim to produce beautiful diagnostics by default,
especially for new users just beginning to use LLVM. However,
different users have different preferences, and sometimes LLVM is
driven by another program that requires the diagnostic output to be
simple and consistent rather than user-friendly. For these cases,
LLVM provides a wide range of options to control the output format of
the diagnostics that it generates.
- **-fcaret-diagnostics** | **-fno-caret-diagnostics**
- Print source line and ranges from source code in diagnostic format.
This option controls whether LLVM prints the source line, source
ranges, and caret when emitting a diagnostic. The default setting is
enabled. When enabled, LLVM prints information like the following
example:
test.c:28:8: warning: extra tokens at end of #endif directive
[-Wextra-tokens]
#endif bad
^
//
Copy to clipboard
- **-fdiagnostics-format=(clang|msvc|vi)**
- Changes diagnostic output format to better match IDEs and command
line tools.
This option controls the output format of the filename, line number,
and column printed in diagnostic messages. The default setting is
clang. The effect of the setting the output format is shown in the
following examples.
- clang
t.c:3:11: warning: conversion specifies type 'char *' but the
argument has type 'int'
Copy to clipboard
- msvc
t.c(3,11) : warning: conversion specifies type 'char *' but the
argument has type 'int'
Copy to clipboard
- vi
t.c +3:11: warning: conversion specifies type 'char *' but the
argument has type 'int'
Copy to clipboard
- **-fdiagnostics-show-option** | **-fno-diagnostics-show-option**
- Enable [-W<option>] information in diagnostic line.
This option controls whether LLVM prints the associated warning group
option name ([Section 4.3.30.3](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#diagnostic-categories)) when
outputting a warning diagnostic. The default setting is disabled.
For example, given the following diagnostic output:
test.c:28:8: warning: extra tokens at end of #endif directive
[-Wextra-tokens]
#endif bad
^
//
Copy to clipboard
In this case, specifying `-fno-diagnostics-show-option` prevents LLVM
from printing the [-Wextra-tokens] information in the diagnostic
output. This information indicates the option that is required to
enable or disable the diagnostic, either from the command line or by
using the GCC diagnostic pragma ([control diagnostics with pramas](https://docs.qualcomm.com/doc/80-VB419-99/topic/use_the_compilers.html#sec-control-diagnostics-with-pragmas)).
- **-fdiagnostics-show-category=(none|id|name)**
- Enables printing category information in diagnostic line.
This option controls whether LLVM prints the category associated with
a diagnostic when emitting it. The default setting is none. The
effect of the setting the output format is shown in the following
examples.
- none
t.c:3:11: warning: conversion specifies type 'char \*' but the
argument has type 'int' [-Wformat]
Copy to clipboard
- id
t.c:3:11: warning: conversion specifies type 'char \*' but the
argument has type 'int' [-Wformat,1]
Copy to clipboard
- name
t.c:3:11: warning: conversion specifies type 'char \*' but the
argument has type 'int' [-Wformat,Format String]
Copy to clipboard
Each diagnostic can have an associated category. If it has one, it is
listed in the diagnostic category field of the diagnostic line (in
the [] brackets).
This option can be used to group diagnostics by category, so it
should be a high-level category; the goal is to have dozens of
categories, not hundreds or thousands of them.
- **-fdiagnostics-print-source-range-info** | **-fno-diagnostics-print-source-range-info**
- Print machine-parseable information about source ranges.
This option controls whether LLVM prints information about source
ranges in a machine-parseable format after the file/line/column
number information. The default setting is disabled. The information
is a simple sequence of brace-enclosed ranges, where each range lists
the start and end line/column locations.
For example, given the following output:
exprs.c:47:15:{47:8-47:14}{47:17-47:24}: error: invalid operands to binary expression ('int *' and '_Complex float')
P = (P-42) + Gamma*4;
~~~~~~ ^ ~~~~~~~
Copy to clipboard
In this case, -fdiagnostics-print-source-range-info generates the
braces, {}.
The printed column numbers count bytes from the beginning of the
line; take care if the source contains multiple-byte characters.
- **-fdiagnostics-parseable-fixits**
- Prints Fix-Its in a machine-parseable format.
This option makes LLVM print available Fix-Its in a machine-parseable
format at the end of diagnostics. The following example illustrates
the format:
`fix-it:"t.cpp":{7:25-7:29}:"Gamma"`
In this case, the range printed is half-open, so the characters from
column 25 up to (but not including) column 29 on line 7 of file t.cpp
should be replaced with the string Gamma. Either the range or
replacement string can be empty (representing strict insertions and
strict erasures, respectively). Both the filename and insertion
string escape backslash (as \\), tabs (as \t), newlines (as \n),
double quotes (as \”), and non-printable characters (as octal
\xxx).
The printed column numbers count bytes from the beginning of the
line; take care if the source contains multiple-byte characters.
- **-fdiagnostics-show-template-tree**
- For large templated types, this option causes LLVM to display the
templates as an indented text tree, with one argument per line, and
any differences marked inline.
- default
t.cc:4:5: note: candidate function not viable: no known conversion
from 'vector