Standard S32DS C/C++ Compiler

This Standard S32DS C/C++ Compiler page displays the build configuration settings that apply to the set up the Standard S32DS C/C++ Compiler tool .

Table 1. Application and Library Project Properties: Standard S32DS C/C++ Compiler
Setting Description
Command The command pattern for the ${COMMAND} variable. This variable is used in the Command line pattern field (below). Default patterns:
  • C compiler: ${cross_prefix}${cross_c}${cross_suffix}
  • C++ compiler: ${cross_prefix}${cross_cpp}${cross_suffix}

The patterns use the build variables specified on the Cross Settings page.

All options This read-only field aggregates all flags specified across all pages inside the compiler settings. The compiler will be called with these flags during the build process.
Command line pattern The command line pattern to call the compiler.

Default:

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

Dialect

The Dialect page specifies the programming language standard and options to which the Standard S32DS C/C++ Compiler will conform.

Table 2. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Dialect
Setting Description
Language standard The language standard to which the code should conform. The compiler accepts all programs that follow the specified standard plus GNU extensions that do not contradict it. Options:
  • C language: ISO C90/ANSI C89 (-std=c90), ISO C99 (-std=c99), ISO C11 (-std=c11), ISO C17 (-std=c17)
  • C++ language: ISO C++98 (-std=c++98), ISO C++11 (-std=c++11), ISO C++14 (-std=c++14), ISO C++17 (-std=c++17)

Default: no option selected (the factory GCC standard applies).

For more information, consult the GCC documentation at gcc.gnu.org.

Other dialect flags Additional dialect options. You can specify any language options supported by GCC. Consult the GCC documentation.

Preprocessor

The Preprocessor page specifies the settings required by the GCC compiler for preprocessing source files.

Table 3. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Preprocessor
Setting Description
Do not search system directories (-nostdinc) This option instructs the compiler to not search the system locations for header files. Only the locations specified on the Includes page will be searched.
Preprocess only (-E) This option instructs the compiler to preprocess source files without doing the compilation step.
Note: Selecting this option causes the linker to throw an error at build time. The linker expects an object file which is not created by the compiler.
Defined symbols (-D) The prioritized list of symbols defined as macros.

This option is similar to the #define directive but applies to all assembly-language modules in a build target.

Undefined symbols (-U) The prioritized list of canceled symbols, both built-in and defined with the -D option.
Do not search system C++ directories (-nostdinc++) This option instructs the C++ compiler to not search the system locations for header files.

This option is only available for C++ projects.

Includes

The Includes page specifies header files to be used during compilation and the file paths to be searched for header files.

Table 4. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Includes
Setting Description
Include paths (-I) The prioritized list of directories to be searched for header files. These directories are searched before the standard system include directories.

Default paths: "${ProjDirPath}/include"

Include files (-include) The prioritized list of header files to be included.

Optimization

The Optimization page specifies optimizations run by the Standard S32DS C/C++ Compiler tool during the compilation of a program. Turning on optimization flags makes the C/C++ compiler attempt to improve the performance and code size at the expense of the compilation time and the ability to debug the program.

Table 5. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Optimization
Setting Description
Optimization level The level of optimization assigned for the compiler. Options:
  • None (-O0): Disables optimization. This option instructs the compiler to generate unoptimized, linear assembly-language code. This reduces the compilation time.
  • Optimize (-O1): The compiler performs all target-independent (non-parallelized) optimizations such as function inlining, omits all target-specific optimizations, and generates linear assembly-language code. Optimizing takes somewhat more time, and a lot more memory for a large function.
  • Optimize more (-O2): The compiler performs all optimizations, target-independent and target-specific, and outputs optimized, non-linear, parallelized assembly-language code. This option increases both the compilation time and the performance of the generated code.
  • Optimize most (-O3): The compiler performs all -O2 optimizations, after which the low-level optimizer performs global-algorithm register allocation. At this optimization level, the compiler generates code that is usually faster than the code generated from -O2 optimizations.
  • Optimize for size (-Os): The compiler performs further optimizations designed to reduce the code size. At this optimization level, the compiler performs all -O2 optimizations that do not typically increase the code size. The resulting binary file has a smaller executable code size, as opposed to a faster execution speed.
Other optimization flags Additional optimization flags supported by GCC and not otherwise available on this page. Consult the GCC documentation at gcc.gnu.org.
'char' is signed

(-fsigned-char)

This option instructs the compiler to treat char strings as signed char strings.
'bitfield' is unsigned

(-funsigned-bitfields)

This option instructs the compiler to treat bit fields as unsigned.
Function sections

(-ffunction-sections)

This option instructs the compiler to place each function into a separate section in the binary artifact. Each function section will be given the name of the specific function placed in the section.
Note: This option makes the assembler and linker create larger object and executable files and work slower.
Data sections (-fdata-sections) This option instructs the compiler to place each data item into its own section in the output file. The name of the data item determines the section's name in the output file.
Note: This option makes the assembler and linker create larger object and executable files and work slower.
No common uninitialized

(-fno-common)

This option instructs the compiler to place uninitialized global variables in the data section of the object file rather than generating them as common blocks.

This has the effect that if the same variable is declared (without extern) in two different compilations, you get a multiple-definition error when you link them. In this case, you must compile with -fcommon instead. Compiling with -fno-common is useful on targets for which it provides better performance, or if you wish to verify that the program will work on other systems that always treat uninitialized variable declarations this way.

Do not inline functions

(-fno-inline-functions)

This option instructs the compiler to not consider any functions for inlining, even if they are not declared inline.
Assume freestanding environment (-ffreestanding) This option instructs the compiler to assert that compilation targets a freestanding environment.

This implies the use of the Disable builtin option (below). A freestanding environment is one in which the standard library may not exist, and the program startup may not necessarily be at main.

Disable builtin (-fno-builtin) This option instructs the compiler to not recognize built-in functions that do not begin with the __builtin_ as prefix.
Single precision constants

(-fsingle-precision-constant)

This option instructs the compiler to treat floating-point constants as single-precision instead of implicitly converting them to double-precision constants.
Link-time optimizer (-flto) This option instructs the compiler to run the standard link-time optimizer. When invoked with source code, it generates GIMPLE (one of GCC's internal representations) and writes it to special ELF sections in the object file. When the object files are linked together, all the function bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit.
Disable loop invariant move

(-fno-move-loop-invariants)

This option instructs the compiler to disable the loop invariant motion pass in the RTL loop optimizer.

This option is available at optimization level “-O1”.

Debugging

The Debugging page specifies the debugging parameters to be used by the Standard S32DS C/C++ Compiler tool. The specified parameters affect the debugging information that will be available in the resulting build target: ELF executable file or A library file.

Table 6. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Debugging
Setting Description
Debug Level The debugging level assigned to the compiler. Options:
  • None: Disables output of debugging information to the build artifact.
  • Minimal (-g1): Enables the generation of minimum debugging information. This includes descriptions of functions and external variables and line number tables, but no information about local variables.
  • Default (-g): Enables the generation of DWARF 1.x conforming debugging information.
  • Maximum (-g3): Enables the generation of extra debugging information (such as all macro definitions) for the compiler to provide maximum debugging support.
Other debugging flags Additional debugging flags supported by GCC and not otherwise available on this page. Consult the GCC documentation at gcc.gnu.org.
Generate gcov information

(-ftest-coverage -fprofile-arcs)

This option tells the compiler to generate additional information (basically a flow graph of the program) and to include additional code in the object files for generating the extra profiling information. These additional files are placed in the directory where the object file is located.

The gcov code-coverage utility can use these additional files to test coverage of the program.

Sanitize address

(-fsanitize=address)

This option enables sanitizer that uses a hardware ability to ignore the top byte of a pointer to allow the detection of memory errors with a low memory overhead. Memory access instructions are instrumented to detect out-of-bounds and use-after-free bugs.
Note: The option cannot be combined with -fsanitize=thread or -fsanitize=address
Sanitize pointer operations

(-fsanitize=pointer-compare -fsanitize=pointer-subtract)

Instrument comparison operation and subtraction with pointer operands.
Note: The option must be combined with -fsanitize=address.
Note: The option cannot be combined with -fsanitize=thread.
Sanitize data race in multi-thread

(-fsanitize=thread)

This option enables fast data race bugs detector.
Note: The option cannot be combined with -fsanitize=address, -fsanitize=leak.
Note: Sanitized atomic builtins cannot throw exceptions when operating on invalid memory addresses with non-call exceptions.
Sanitize memory leak

(-fsanitize=leak)

This option enables memory leak detector. It only matters for linking of executables and the executable is linked against a library that overrides malloc and other allocator functions.
Note: The option cannot be combined with -fsanitize=thread.
Sanitize undefined behavior

(-fsanitize=undefined)

This option enables fast undefined behavior detector.
Debug format The debug information format to be used by the compiler when writing debug info to the produced ELF file.

Options: Toolchain default, gdb, stabs, stabs+, dwarf-2, dwarf-3, dwarf-4, dwarf-5

Note: Please note that the debugging format "dwarf-5" is available only with GCC 11.4.

Default: Toolchain default.

Warnings

The Warnings page specifies options used by the compiler to display warning messages during the compilation. These options specify what types of warning messages will be output in the console during the compilation.

Table 7. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Warnings
Setting Description
Check syntax only

(-fsyntax-only)

This option instructs the compiler to only check the code for syntax errors.
Pedantic (-pedantic) This option instructs the compiler to issue warnings when a program is rejected because of forbidden extensions or non-conformance to ISO C and ISO C++ standards.

Not all non-ISO constructs get warnings. To learn more, consult the GCC documentation at gcc.gnu.org.

Pedantic warnings as errors

(-pedantic-errors)

This option instructs the compiler to issue errors rather than warnings in cases described in the Pedantic option (above).
Inhibit all warnings (-w) This option instructs the compiler to inhibit all warning messages.
All warnings (-Wall) This options enables a group of GCC warning options on the compiler. This includes all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. This also enables some language-specific warnings. To learn more, consult the GCC documentation at gcc.gnu.org.
Extra warnings (-Wextra) This option instructs the compiler to enable some extra GCC warning options that are not enabled by All warnings (above). For details, consult the GCC documentation at gcc.gnu.org.
Warnings as errors (-Werror) This option instructs the compiler to turn all warnings into hard errors.

The source code which triggers warnings will be rejected. The specifier for a warning is appended.

Implicit conversions warnings

(-Wconversion)

This option instructs the compiler to issue warnings for implicit conversions that may alter a value.

This includes conversions between real and integer, between signed and unsigned, and conversions to smaller types. No warning will be issued for explicit casts like abs ((int)x) and ui=(unsigned)-1, or if the value is not changed by the conversion.

Pointer cast with different alignment

(-Wcast-align)

This option instructs the compiler to issue a warning whenever a pointer is cast such that the required alignment of the target is increased.
Removing type qualifier from cast target type

(-Wcast-qual)

This option instructs the compiler to issue a warning whenever a pointer is cast so as to remove a type qualifier from the target type. Also warn when making a cast that introduces a type qualifier in an unsafe way.
All ctor and dtor private

(-Wctor-dtor-privacy)

This option instructs the compiler to issue a warning 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. Also warn if there are no non-private methods, and there’s at least one private member function that isn’t a constructor or destructor.

This option is only available for C++ projects.

Requested optimization pass is disabled

(-Wdisabled-optimization)

This option instructs the compiler to issue a warning 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 optimizers are unable to handle the code effectively.
Suspicious uses of logical operators

(-Wlogical-op)

This option instructs the compiler to issue warnings about suspicious uses of logical operators in expressions. This includes using logical operators in contexts where a bit-wise operator is likely to be expected. Also warns when the operands of a logical operator are the same.
Global function without previous declaration

(-Wmissing-declarations)

This option instructs the compiler to issue a warning if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files.
User-supplied include directory does not exist

(-Wmissing-include-dirs)

This option instructs the compiler to issue a warning if a user-supplied include directory does not exist.
Noexcept false but never throw exception

(-Wnoexcept)

This option instructs the compiler to issue a warning if the C++17 feature making noexcept part of a function type changes the mangled name of a symbol relative to C++14.

This option is only available for C++ projects.

C-style cast used

(-Wold-style-cast)

This option instructs the compiler to issue a warning if an old-style (C-style) cast to a non-void type is used within a C++ program. The new-style casts (dynamic_cast, static_cast, reinterpret_cast, and const_cast) are less vulnerable to unintended effects and much easier to search for.

This option is only available for C++ projects.

Function hides virtual functions from base class

(-Woverloaded-virtual)

This option instructs the compiler to issue a warning when a function declaration hides virtual functions from a base class.

This option is only available for C++ projects.

More than one declaration in the same scope

(-Wredundant-decls)

This option instructs the compiler to issue a warning if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing.
Local symbol shadows upper scope symbol

(-Wshadow)

This option instructs the compiler to issue a warning whenever a local variable or type declaration shadows another variable, parameter, type, class member, or instance variable, or whenever a built-in function is shadowed. If this warning is enabled, it includes also all instances of local shadowing.
Implicit conversions that may change the sign

(-Wsign-conversion)

This option instructs the compiler to issue warnings for implicit conversions that may change the sign of an integer value, like assigning a signed integer expression to an unsigned integer variable. An explicit cast silences the warning.
Overload resolution promotes unsigned to signed type

(-Wsign-promo)

This option instructs the compiler to issue a warning when 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.

This option is only available for C++ projects.

Use of an uncasted NULL as sentinel

(-Wstrict-null-sentinel)

This option instructs the compiler to issue a warning about the use of an uncasted NULL as sentinel. When compiling only with GCC this is a valid sentinel, as NULL is defined to __null. Although it is a null pointer constant rather than a null pointer, it is guaranteed to be of the same size as a pointer. But this use is not portable across different compilers.

This option is only available for C++ projects.

A switch statement does not have a default case

(-Wswitch-default)

This option instructs the compiler to issue a warning whenever a switch statement does not have a default case.
An undefined identifier is evaluated in an #if directive

(-Wundef)

This option instructs the compiler to issue a warning if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero.
Treat strings always as const

(-Wwrite-strings)

When compiling C, this option instructs the compiler to give string constants the type const char[length] so that copying the address of one into a non-const char * pointer produces a warning.

When compiling C++, this option instructs the compiler to issue warnings about the deprecated conversion from string literals to char.

Effective C++ guidelines

(-Weffc++)

This option instructs the compiler to issue warnings about violations of the following style guidelines from Scott Meyers’ Effective C++ series of books. To learn more, consult the GCC documentation at gcc.gnu.org.
Note: When selecting this option, be aware that the standard library headers do not obey all of these guidelines; use grep -v to filter out those warnings.

This option is only available for C++ projects.

Direct float equal check

(-Wfloat-equal)

This option instructs the compiler to issue warnings if floating-point values are used in equality comparisons.
Warn on uninitialized variables

(-Wuninitialized)

This option instructs the compiler to issue a warning if an automatic variable is used without first being initialized or if a variable may be clobbered by a setjmp call.
Warn on various unused elements (-Wunused) This option instructs the compiler to issue warnings if constructs are unused.
Warn if padding is included

(-Wpadded)

This option instructs the compiler to issue a warning if padding is included in a structure, either to align an element of the structure or to align the whole structure.
Warn if floats are compared as equal (-Wfloat-equal) This option instructs the compiler to issue warnings if floating-point values are used in equality comparisons.
Warn if shadowed variable

(-Wshadow)

This option instructs the compiler to issue a warning whenever a local variable or type declaration shadows another variable, parameter, type, or class member (in C++), or whenever a built-in function is shadowed.
Note: In C++, the compiler warns if a local variable shadows an explicit typedef, but not struct, or class, or enum.
Warn if pointer arithmetic

(-Wpointer-arith)

This option instructs the compiler to issue a warning about anything that depends on the size of a function type or of void.

GNU C assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions.

Warn if suspicious logical ops (-Wlogical-op) This option instructs the compiler to issue warnings about suspicious uses of logical operators in expressions.

This includes using logical operators in contexts where a bit-wise operator is likely to be expected.

Warn if struct is returned

(-Waggregate-return)

This option instructs the compiler to issue a warning if any functions that return structures or unions are defined or called.
Warn on undeclared global function

(-Wmissing-declaration)

This option instructs the compiler to issue a warning if a global function is defined without a previous declaration.

Use this option to detect global functions that are not declared in header files.

Other warning flags Additional command line options. Specify any options that control warning output in GCC and not otherwise available on this page. Consult the GCC documentation at gcc.gnu.org.

Miscellaneous

The Miscellaneous page specifies auxiliary compiler options not otherwise available on other pages of the Standard S32DS C/C++ Compiler settings.

Table 8. Application and Library Project Properties: Standard S32DS C/C++ Compiler > Miscellaneous
Setting Description
Other flags Additional command line options. Specify compiler options supported by GCC and not otherwise available on this page. Consult the GCC documentation at gcc.gnu.org.

Default flags: -c -fmessage-length=0.

Verbose (-v)

This option enables verbose output during the compilation and instructs the compiler to display detailed information about the exact sequence of commands used to compile the program.
Note: S32 Design Studio supports output of error messages only. Warning messages and other informational messages will not be output to the console.

Support ANSI programs

(-ansi)

This option configures the compiler to operate in strict ANSI mode. This option is only available for the Standard S32DS C Compiler.

This option turns off certain features of GCC that are incompatible with ISO C90 (when compiling C code), or of standard C++ (when compiling C++ code), such as the asm and typeof keywords, and predefined macros such as unix and vax that identify the type of system you are using. It also enables the undesirable and rarely used ISO trigraph feature. For the C compiler, it disables recognition of C++ style “//” comments as well as the inline keyword.

The macro __STRICT_ANSI__ is predefined when this option is used. Some header files may notice this macro and refrain from declaring certain functions or defining certain macros that the ISO standard does not call for.

Functions that are normally built in but do not have semantics defined by ISO C (such as alloca and ffs) are not built-in functions when this option is used.

Position Independent Code

(-fPIC)

This option instructs the compiler to generate position-independent code (PIC), if supported by the target processor.
Hardening options (-fstack-protector-all -Wformat=2 -Wformat-security -Wstrict-overflow) Emit extra code to check for buffer overflows, such as stack smashing attacks. Check calls to printf and scanf, etc., to make sure that the arguments supplied have types appropriate to the format string specified, and that the conversions specified in the format string make sense, plus additional format checks. Also warn about uses of format functions that represent possible security problems. Also it warns about cases where the compiler implements some optimization.
Address randomization

(-fPIE)

This option is similar to -fPIC, but the generated position-independent code can be only linked into executables.

Save temporary files

(--save-temps)

This option instructs the compiler to save the result of preprocessing in a temporary I file and the result of assembling in a S file. The compiler places the files in the Debug folder of the project and names them based on the source file.

Generate assembler listing

(-Wa, -adhlns="$@.lst")

This option enables the compiler to output assembly listing to an LST file.
Assume aligned memory references only

(-mstrict-align)

This option enables the compiler to access addresses not aligned to 16 or 32 bits.
Note: This setting applies to projects created for Cortex-A53.