title: gcc: Undeclared variables in C, but they are declared
body: <p>Below is the first part of a C program I'm writing. gcc is throwing errors during compilation, however, to the effect that <code>set</code>, <code>p</code>, and <code>s1</code> are all undeclared, but they are declared. I'm having this problem with every function in this file, and I don't know what's going wrong. What do I need to do to resolve the problem?</p>
  
  <p>The specific errors for this function:</p>
  
  <pre><code>a9.c: In function `makeaset':
  a9.c:23: error: `set' undeclared (first use in this function)
  a9.c:23: error: (Each undeclared identifier is reported only once
  a9.c:23: error: for each function it appears in.)
  a9.c:23: error: `p' undeclared (first use in this function)
  a9.c:34: error: `s1' undeclared (first use in this function)
  </code></pre>
  
  <p>And the code snippet:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define SIZE 32
  
  struct set {
      char *data;
      int count;
  };
  typedef struct set set;
  
  void makeaset(set **s1)
  {
      int i;
      set *p;
      p = NULL;
      p = malloc(sizeof(set));
      if (p) {
          p-&gt;data = malloc(SIZE);
          if (p-&gt;data) {
              for (i = 0; i &lt; SIZE; i++)
                  p-&gt;data[i] = 0;
              p-&gt;count = 0;
          }
      }
      *s1 = p;
  }
  </code></pre>