Ошибки при компиляции примера из книги ANSI C, глава Linked Lists

Я делаю некоторые примеры из старой книги по C [A First Book of ANSI C] и получаю ошибку при попытке скомпилировать этот пример кода:

#include <stdio.h>

struct tele_typ {
  char name[30];
  char phone_no[15];
  struct tele_typ *nextaddr;
};

main() {
  struct tele_typ t1 = {"Acme, Sam", "(201) 555-6678"};
  struct tele_typ t2 = {"Dolan, Edith", "(213) 682-3104"};
  struct tele_typ t3 = {"Lanfrank, John", "(415) 718-4581"};
  tele_typ *first;    /* create a pointer to a structure */

  first = &t1;          /* store t1's address in first */
  t1.nextaddr = &t2;    /* store t2's address in t1.nextaddr */
  t2.nextaddr = &t3;    /* store t3's address in t2.nextaddr */
  t3.nextaddr = NULL;   /* store the NULL address in t3.nextaddr */

  printf("\n%s %s %s",first->name,t1.nextaddr->name,t2.nextaddr->name);
}

...и вывод от gcc newstruct.c -o newstruct:

newstruct.c: In function 'main':
newstruct.c:13:3: error: unknown type name 'tele_typ'
newstruct.c:15:9: warning: assignment from incompatible pointer type [enabled by default]
newstruct.c:20:28: error: request for member 'name' in something not a structure or union

Это глава 10.4 о связанных списках. Это ошибка в книге? Или что-то изменилось в стандартах/gcc version 4.6.2 20120120 (prerelease)? Спасибо!

5
задан nak 10 February 2012 в 02:30
поделиться