Common C Compile/Build Errors

Overview

These C compile/build errors and warnings are talked about largely in relation to embedded systems (i.e. microcontrollers).

“pointer of type void used in arithmetic”

Usually occurs when you are doing memory arithmetic, and can actually be a warning you ignore!

“elf section ‘.bss’ will not fit in region ‘ram’

The .bss section contains all 0-initialized global and static variables. This error normally occurs when you have overly large static variables, or you haven’t allocated the stack/heap sizes correctly.

“Suggested parenthesis around assignment used as a truth value”

This is usually because you’ve forgotten to add the second ‘=’ in the if statement.

“Subscripted value is neither array nor pointer”

Normally occurs when you try and index something like an array which isn’t. For example…

“#pragma once in main file”

This occurs when you incorrectly write “#pragma once” in a .c file (even though the error would suggest it, it doesn’t have to be main.c). “#pragma once” is a header guard which prevents an .h file from being included twice in a project and causing multiple declaration/definition errors. Hence “#pragma once” should be only place in .h files. It is an alternative to the “#ifndef” header guard style (see this page for more info).

“variable or field declared void”

This can occur when you declare/define a function in C++ and the compiler doesn’t recognise one of the data types used for an input variable. It will precede a “<variable> was not declared in scope” error.

“macro names must be identifiers”

If you get the error  macro names must be indentifiers it is usually because you have been using both #if()  and #ifdef directives, and accidentely used the combination  #ifdef() . This is not allowed! When using #ifdef, do not enclose the proceeding identifier with brackets.

“Not In Formal Parameter List”

Applies To: Keil C51 Compiler

The “not in formal parameter list” build error is most likely to occur when you have forgotten to add the semi-colon at the end of a function declaration. Without the semi-colon, the compiler continues to read onto the following lines, and usually produces this error. Check the first first function declaration preceding this error for a missing semi-colon.

double free or corruption

Error Type: Run Time

This error normally codes with another keyword at the end, e.g.

It normally occurs when you accidently free() the same piece of memory twice. I have also got this error due to a incremental-build bug in the Xilinx SDK (xsdk) for it’s Zynq FGPA’s/microncontroller chips.