delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/13/09:30:00

Date: Mon, 13 Oct 1997 15:27:45 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Jamie Love <jamie DOT love AT clear DOT net DOT nz>
cc: djgpp AT delorie DOT com
Subject: Re: Difference between struct setups
In-Reply-To: <199710130605.TAA20415@fep1-orange.clear.net.nz>
Message-ID: <Pine.SUN.3.91.971013152456.11407a-100000@is>
MIME-Version: 1.0

On Tue, 14 Oct 1997, Jamie Love wrote:

> during my forays into the allegro code, i noticed that structs are set up
> like:
> 
> typedef struct X
>  {
>     .....
>  } X;
> ...
> X x;
> 
> Now, when i was programming in borlands compiler, i just went:
> 
> struct X
>  {
>    .....
>  };
> ...
> X x;
> 
> So, what is the difference??

The last line is not a legal C syntax.  You need to say "struct X x;" 
instead.  When you use typedef, you tell the compiler that type X is a 
kind of alias to "struct X".

Please note that this discussion is a bit off-topic here; if you want to 
discuss it further, please post to comp.lang.c.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019