title: C : typedef struct name {...}; VS typedef struct{...} name;
body: <p>As the title says, I have this code:</p>
  <pre class="lang-c prettyprint-override"><code>    typedef struct Book{
          int id;
          char title[256];
          char summary[2048];
          int numberOfAuthors;
          struct Author *authors;
      };
  
  
      typedef struct Author{
          char firstName[56];
          char lastName[56];
      };
  
  
      typedef struct Books{
          struct Book *arr;
          int numberOfBooks;
      };
  </code></pre>
  <p>I get these errors from gcc :</p>
  <pre><code>bookstore.c:8:2: error: unknown type name ‘Author’
  bookstore.c:9:1: warning: useless storage class specifier in empty declaration [enabled by default]
  bookstore.c:15:1: warning: useless storage class specifier in empty declaration [enabled by default]
  bookstore.c:21:2: error: unknown type name ‘Book’
  bookstore.c:23:1: warning: useless storage class specifier in empty declaration [enabled by default]
  </code></pre>
  <p>No warnings and no errors occur if I change the typedefs like this:</p>
  <pre class="lang-c prettyprint-override"><code>    typedef struct{
          char firstName[56];
          char lastName[56];
      } Author;
  </code></pre>
  <p>Having searched through <em><a href="https://rads.stackoverflow.com/amzn/click/com/0131103628" rel="noreferrer" rel="nofollow noreferrer">C Programming Language, 2nd Edition</a></em> and googled for a couple of hours, I can't figure out why the first implementation won't work.</p>