delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/13/05:22:16

From: G DOT DegliEsposti AT ads DOT it
To: djgpp AT delorie DOT com
Message-ID: <C125652F.00313714.00@vega.ads.it>
Date: Mon, 13 Oct 1997 12:10:57 +0200
Subject: Re: Difference between struct setups
Mime-Version: 1.0





>Hi,
>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??

I am not an ANSI guru, so I am not sure if what I sy is exact:
I think that the second declaration is a sort of a Borland extension to the
C language, maybe it comes from the C/C++ mixture of Borland compilers
and it is not strict ANSI C.

If I remember well, in C, types X and struct X are not equivalent while in
C++ they are.

>I have trouble also understanding why i couldn't use the second setup in
my
>c code in a small test program i made (it gave me many errors) while in
>another program i could go:
>
>struct X
> {
>   .....
> }y;
This is true, because this is not equivalent to:

X y;

it is equivalent to:

struct X {...};
struct X y;

ciao
  Giacomo


- Raw text -


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