News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

C struct question

Started by rags, November 11, 2008, 03:06:04 AM

Previous topic - Next topic

rags

I am not familiar with c, and was looking at some c code and came across this struct def:


typedef struct _Info
{
.....
       .....
       some declarations
      ......
} Info;


Is this a structure named Info of type _Info or is it the otherway around?
thanks
God made Man, but the monkey applied the glue -DEVO

hutch--

Mike,

The trailing name is the one to use. A C compiler reads the structure in a linear manner from "{" to "}" then reads the name after it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

rags

thanks for the quick reply Hutch
God made Man, but the monkey applied the glue -DEVO

BogdanOntanu

Not exactly

This is the lazy version of 2 statements: one for the typedef and another one for the structure.

Hence in this "single" compound statement the structure _Info is defined in the inner part of the statement and then a new type is created in the outer part of the statement. A type named "Info" that is typedf'ed as being the same as "struct _Info".

The struct _Info also does exist for the compiler.

This typedef is usually made because people do not like to type "struct _Info" all over the place.

But Hutch is right in the short answer: the last name is the one that is usually used.

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro