AME 3623: Compiler Hints

Resolving Compiler Errors

The C compiler is what we call a "one pass compiler": it touches all of the lines in your C programs exactly once (and in-order). In addition, an error at one point in your code can cause other error messages later. If you have a series of compiler errors, always start at the top of the list and work your way down (often, compiling with each fix).

Compiler Warnings

Our C compiler can generate lots of warnings. Often, they are indications of problems in your code that need to be fixed. It is always good practice to try to resolve warnings, even if the compiler happily generates an executable program.

Importing Libraries into the Arduino Environment

Additional libraries are often provided as zip files, which can be imported directly into your Arduino environment (they are placed in Arduino/libraries). If you also unpack this zip file into your project folder, this can cause conflicts in the compilation process. These conflicts will generate a compiler warning, which should be resolved by removing the copy that is local to your project.

printf()

The proper use of printf() in the Arduino environment is either Serial.printf() or SerialX.printf() (where X can be a number corresponding to the serial port number).

If you insert printf() into your code, the compiler will not call the correct functions. As of version 1.8.10, the error that you will see is "_write() not resolved". The solution is to replace printf() with one of the above forms.


andrewhfagg at gmail.com

Last modified: Fri Feb 28 17:19:04 2020