Here is the list of the most common C errors we have seen students experience in Mimir Classroom. The list of errors will continue to grow as we learn from students' work and as we hear from instructors like you send recommendations.
control reaches end of non-void function [-Werror=return-type]
This typically indicates that one of your functions was declared to have a return type (non-void function) but it is not returning a value. Check that every non-void function returns the expected value.
ld returned 1 exit status
This typically means that you have variables not defined and the most common cause are typos and spelling mistakes. Check for spelling differences.
stray ‘\342’ in program
This means that one of your double quotation marks are invalid Unicode characters. C and C++ don't allow "smart" quotes (i.e. ” vs "). This usually happens when you copy and paste code from other sources or use a text editor that uses Unicode. To fix these error just replace the Unicode quotation marks using your keyboard.
expected ‘;’ before ‘}’ token
This is typically a syntax error. Make sure that for every opening parentheses or bracket there is a matching closing one and that every statement ends with a semi-colon.
You can read more about semi-colons and statements here: http://www.cplusplus.com/doc/tutorial/control/
subscripted value is neither array nor pointer nor vector
This error refers to your use of the subscript operator to access values in an array, pointer of vector. For example, you've declared a single-dimensional array but you're trying access it as a two-dimensional:
int newArray[4];
newArray[4][4] = ...;
no input files
This means the file that the compiler is trying to compile doesn't exist. Make sure the file you're calling exists in the directory you're in and that the extensions are either ".c" or ".h".
expected declaration or statement at end of input
This is typically a syntax error. Make sure that for every opening parentheses or bracket there is a matching closing one and that every statement ends with a semi-colon.
You can read more about semi-colons and statements here: http://www.cplusplus.com/doc/tutorial/control/
suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
This error is an indication that your if-else conditional statements are missing parentheses. You can read more about if-else statement syntax here: http://www.cplusplus.com/doc/tutorial/control/
unknown type name ‘bool’
Some older versions of C don't allow 'bool' as variable types. If you believe your version of C allows it, make sure you're importing the correct libraries. You can read more about using boolean variables in C here: https://en.cppreference.com/w/c/types/boolean
statement with no effect [-Werror=unused-value]
This can happen due to a multitude of reasons, the most common stems from missing characters that make the statement invalid, i.e., you may have a line of code that doesn't do anything due to a missing character, operator, or parentheses. For example:
int x = 0;
int y = 2;
x == y;
The last line is comparing two variables but the result of the comparison (true or false) is not being used.
expected identifier or ‘(’ before ‘}’ token
This typically means that the placement of your parentheses and curly brackets is incorrect. Make sure you're using the correct syntax, that your statements end with a semi-colon, and that for every opening parentheses and curly bracket has a closing one.
Read more about C syntax here: http://www.cplusplus.com/doc/tutorial/control/
too many arguments for format [-Werror=format-extra-args]
Typically this refers to the amount and type of arguments passed into a function do not match the expected amount and types in the function declaration.
You can read more about function arguments and syntax here: http://www.cplusplus.com/doc/tutorial/functions/
stray ‘\\222’ in program
This usually happens when you copy and paste code from other sources or use a text editor that uses Unicode. To fix these error just replace the Unicode quotation marks or white spaces using your keyboard.
stray ‘\\210’ in program
This usually happens when you copy and paste code from other sources or use a text editor that uses Unicode. To fix these error just replace the Unicode quotation marks or white spaces using your keyboard.