You copied the Doc URL to your clipboard.

Controlling diagnostic messages

Arm® Compiler provides diagnostics messages in the form of warnings and errors. You can use options to suppress these messages or enable them as either warnings or errors.

Arm Compiler lists all the warnings and errors it encounters during the compiling and linking process. However, if you specify multiple source files, and Arm Compiler encounters an error from a source file, it does not report any diagnostic information from the other source files that it has not processed.

Diagnostic messages from Arm Compiler include the following information:

  • Name of file that contains the error or warning.
  • Line number in the file that contains the error or warning.
  • Character in the line that is associated with the error or warning.
  • Description of the error or warning.
  • A diagnostic flag of the form -Wflag, for example -Wvla-extension, to identify the error or warning. Only the messages that you can suppress have an associated flag. Errors that you cannot suppress do not have an associated flag.

An example warning diagnostic message is:

file.c:8:7: warning: variable length arrays are a C99 feature [-Wvla-extension]
 int i[n];
      ^

This warning message tells you:

  • The file that contains the problem is called file.c.
  • The problem is on line 8 of file.c, and starts at character 7.
  • The warning is about the use of a variable length array i[n].
  • The flag to identify, enable or disable this diagnostic message is vla-extension.

The following are common options that control diagnostic output from Arm Compiler.

Table 2-4 Common diagnostic options

Option Description
-Werror Turn all warnings into errors.
-Werror=foo Turn warning flag foo into an error.
-Wno-error=foo Leave warning flag foo as a warning even if -Werror is specified.
-Wfoo Enable warning flag foo.
-Wno-foo Suppress warning flag foo.
-w Suppress all warnings. Note that this is a lowercase w.
-Weverything Enable all warnings.

See Controlling Errors and Warnings in the Clang Compiler User's Manual for full details about controlling diagnostics with armclang.

Examples of controlling diagnostic messages

Copy the following code example to file.c and compile it with Arm Compiler to see example diagnostic messages.

#include <stdlib.h>
#include <stdio.h>

void function (int x) {
    int i;
    int y=i+x;

    printf("Result of %d plus %d is %d\n", i, x); /* Missing an input argument for the third %d */
    call(); /* This function has not been declared and is therefore an implicit declaration */

    return;
}

Compile file.c using:

armclang --target=aarch64-arm-none-eabi -march=armv8 -c file.c

By default armclang checks the format of printf() statements to ensure that the number of % format specifiers matches the number of data arguments. Therefore Arm Compiler generates this diagnostic message:

file.c:9:36: warning: more '%' conversions than data arguments [-Wformat]
				printf("Result of %d plus %d is %d\n", i, x);
                                                     ^

By default armclang compiles for the gnu11 standard for .c files. This language standard does not allow implicit function declarations. Therefore Arm Compiler generates this diagnostic message:

file.c:11:3: warning: implicit declaration of function 'call' is invalid C99 [-Wimplicit-function-declaration]
    call();
    ^

To suppress all warnings, use -w:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -w

To suppress only the -Wformat warning, use -Wno-format:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Wno-format

To enable the -Wformat message as an error, use -Werror=format:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Werror=format

Some diagnostic messages are suppressed by default. To see all diagnostic messages use -Weverything:

armclang --target=aarch64-arm-none-eabi -march=armv8-a -c file.c -Weverything
Was this page helpful? Yes No