Select Warning Messages

During compilation, embedXcode generates two kinds of messages:

  • An error message is highlighted in red and stops the compilation. It points at the line that originated the error.

Error

LED was not declared in this scope.

Examples include unknown variable, unknown function.

  • A warning message is highlighted in yellow and doesn’t stop the compilation. It points at a possible cause of error.

Warning

unusedVariable is an unused variable.

Examples include unused variable, unused function.

Even if a compilation is successful with no error messages, it can generate warning messages that highlight possible possible causes of errors.

By default, the warning messages are switched off.

Select Scope for Warning Messages

This section requires embedXcode+.

The variable WARNING_OPTIONS on the main Makefile selects the scope of the warning messages.

By default, the variable WARNING_OPTIONS is set to 0: no warning messages are reported.

# Warning options
#
WARNING_OPTIONS = 0

If WARNING_OPTIONS is left empty, all warnings are displayed.

# Warning options
#
WARNING_OPTIONS =

This is the same as WARNING_OPTIONS = all.

# Warning options
#
WARNING_OPTIONS = all

The all option usually generates a very long list of warning messages, making the analysis difficult if not impossible. Moreover, only the 200 first messages are displayed.

The solution consists on selecting a scope and targeting specific warnings.

Define the selected warnings by listing the options after the variable WARNING_OPTIONS.

Here are two example I use the most.

  • To check all the unused elements and save precious SRAM and Flash memory, define the following warning options.
# Warning options
#
WARNING_OPTIONS = unused-variable unused-function unused-label unused-value

The variable unusedVariable is defined but not used.

Defining but not using a variable is perfectly allowed, but uses SRAM memory.

  • To check all the the use of NULL, define the following warning options.
# Warning options
#

WARNING_OPTIONS = conversion-null pointer-arith

The myLED variable corresponds to a pin number. Setting it to NULL is a correct operation but may rise an error somewhere else.

There are many other options for selecting warning messages. For more information,

Define Warning Statements

This section requires embedXcode+.

It is also possible to define a warning statement that will raise a warning message during compilation.

  • Type in the following line on the code with a #warning statement followed by the message to display.

To display the list of warning messages and the corresponding lines of code,

  • Select a target and click on Run.

  • Click on the icon of the middle to display the Issue navigator.



Click once on the message highlighted in yellow to display the line where the warning is located.