A typical gcc error message looks like this:
conepainting.c: In function ‘main’: conepainting.c:30: error: ‘KInchesPerFoot’ undeclared (first use in this function)"conepainting.c" is the name of the source file, and ":30:" is the line number where the error was located. The "undeclared" error is a common mistake. All variables must be declared before they are used, and if you forget, you'll see this error. It means the compiler didn't find a declaration for a variable prior to its first use. The error can also occur if you spelled the variable name differently in two places. The compiler is "case-sensitive" so "DOG" and "dog" are two different variables; pay careful attention to upper and lower case letters.
/tmp/ccJiZokm.o: In function `main': conepainting.c:(.text+0x63): undefined reference to `sqrt' collect2: ld returned 1 exit statusYou forgot to compile with the math library. Provide the "-lm" flag (that's the letter "l" not the numeral "1" to the compiler, like this:
gcc -lm conepainting.c
no newline at end of file.
Be sure there is a new line with no blank spaces as the last
line in the file.
warning: ISO C forbids nested functions
Missing closing brace at end of a function.
warning: ISO C90 forbids mixed declarations and code
This error means
you have a declaration after you started writing executable statements.
All variable declarations must be placed at start of the function.
warning: double format, different type arg
Usually this means you specified a floating point placeholder
for an integer variable, or vice versa.
warning: ISO C90 does not support the `%lf' printf
The `%lf' placeholder can only be used with scanf, not
printf.
error: syntax error before '}' token
was caused by a missing semicolon.
error: syntax error before "if"
was generated by this code segment
for ( index = 0; index < kNameLen; index++)
(
if (isalpha(name[index]) )
void sortMessages(message_type list[], numMessages);
because the datatype "int" was missing before
error: invalid type argument of `unary *'
The error was on this line
kPricePerFoot * Feet;
but was caused by this line
#define kPricePerFoot 11;
because #define is not supposed to end in semicolon.
error: syntax error before ';' token
The error was on this line
int list[SIZE];
but was caused by this line
#define SIZE 99;
because #define is not supposed to end in semicolon.
invalid operands to binary %
The remainder operator works only on integers. Make sure both dividend
and divisor are integers.
Example:
number % pow(x,7) won't work because pow() returns a
double.
Undefined first referenced symbol in file pow /var/tmp//cc44C0mS.o ld: fatal: Symbol referencing errors. No output written to a.out collect2: ld returned 1 exit statusThis is an error from the linker (not the compiler). If the undefined symbol is pow, ceil, or any of the math functions, then you forgot to include the -lm flag on the gcc command.