Node:...undeclared (first use in this function), Next:, Previous:Compile-time errors, Up:Debugging

...undeclared (first use in this function)

This is similar to the undefined reference to... error, but instead of referring to an undefined function, you are referring to an undefined variable.

Sometimes this is a scope problem. You might get this error if you tried to refer to another function's local variable. For example:

#include <stdio.h>

void set_value()
  int my_int = 5;

/* To shorten example, not using argp */
int main()
  my_int = 23;
  return 0;

The variable my_int is local to the function set_value, so referring to it from within main results in the following error:

undec.c: In function `main':
undec.c:10: `my_int' undeclared (first use in this function)
undec.c:10: (Each undeclared identifier is reported only once
undec.c:10: for each function it appears in.)