Handling Compiler Errors

If the compiler encounters an error in your code, it sends an error message to the Output window:

Output Micro Build with Error

You can double click anywhere in the line containing the error message and revise your code to eliminate the error.

You can use the [F4] and [Shift+F4] keys to jump to the next/previous error. Sometimes the compiler generates multiple messages for the same error to give more information about the discrepancies it has found.

Using the Error List Window

Mostly, the "Error List" Window is more useful than the output window.

  • To open the Error List Window, choose "View > Error List" from the menu.

Your screen will then look like this:

Error List Window

The Error List shows Errors, Warnings and Intellisense Messages.

Error List Error Icon Errors are mistakes in your source code that keep the compiler from producing code, like referring to a function that does not exist - as in our example.

Error List Warning Icon Warnings are spots in your code that look dubious to the compiler. The compiler can generate code, but it is likely that the code location will bring problems when you sketch runs.

Error List Intellisense Icon Intellisense Messages come from the Intellisense system, details see below

By double clicking a line in the Error List, the editor will put the cursor in the related line

Warning 16 Note:

In order to get warnings from the compiler, you must enable warnings first by choosing the vMicro > Compiler Warnings menu item (read more) and then rebuild your project once.
After enabling warnings, you will also see some warnings from the Arduino core and/or libraries. You can safely ignore them.


Click here for more information about the Error List Window

Intellisense: Detecting errors as you type

Visual Micro provides a technology called Intellisense. Intellisense tries to find errors as your are typing your code in without having to compile your sketch. This saves a lot of time and gives you immediate feedback about the error.

IntelliSense underlines erroneous areas of your code with a red waved line like the  spell checker in your text processing or E-Mail program. If you put the mouse pointer over the underlined portion of your code, a quick tip will show the error:

Intellisense Showing Error

If you have opened the Error List Window, as described above, then Intellisense errors will appear there as well. In this way, you can find errors without having to compile your project, which is very handy.

This error detection in the background will of course also show intermediate errors that only appear because you have not yet finished your typing.

Hints for removing compiler errors

Sometimes the compiler issues many error messages that have the same reason. So don't be shocked if you get lots of error messages, often it's a single mistake that caused all the messages.
The following hints help you to eliminate compiler error messages in an efficient way.

  • Process the errors from top to bottom
    Start with the first messages and fix the error. If the subsequent messages do not appear reasonable for you, they may be consequential errors from the first one. Just recompile your sketch to eliminate the phantom error messages.

  • Curly braces
    If there are lots of error messages in code areas that were correct before, then you might have put too few or too many curly braces ('{', '}') into your code. If you put the cursor on one curly brace and press Ctrl+], Visual Studio will jump to the matching brace. If that matching brace is not the one you expected, then there is an excess  brace somewhere or one is missing.

    Warning 16 Note:

    The key that is assigned to the "Matching brace" function in Visual Studio/Atmel Studio differs depending on the layout of your keyboard. For example, with German keyboards it is Ctrl+´ (accent key left of the backspace key).

    To find out the key assignment on your PC, go to Tools > Options > Keyboard, and  enter "Edit.GotoBrace" in the text box named "Show commands containing". You will see the key assignment in the field named "Shortcuts for selected command". This options windows can also be used to reassign keys.


  • Misplaced breakpoints
    If you have set a breakpoint recently, maybe you have set it at a location where it's not allowed so set one. Read more about where in source code breakpoints can be set.
  • Help in the web
    Find help in the web, for example on www.cprogramming.com or www.stackoverflow.com. Use the error message of the compiler output as a search term there, or enter it in your favorite search engine.

 

Other Pages