question about lamoths book
how come in his book he says that on structs u cant get rid of
typedef struct map; and leave it as struct map;
well when i try to take out the typedef and compile my program i get all kinds of errors but when i put the typedef back in everything is fine
Maybe because typedef structs are to define your own type such as an integer or a double word. Typedef structures can be used for casting an array or pointer of structs with a simple struct only defines one structure.. am I taking in circles again!!??
Just check the way the code accesses the data of the structure either by blah->data or by blah.data.
Just check the way the code accesses the data of the structure either by blah->data or by blah.data.
The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.
?Have a nice day!?
the date of the post was in 1899?? =P. I think it could either be problem on my side or a problem with the CGI code on the server's side. Oh well.. my computer is toast =)
Edited by - GoofProg on July 30, 2000 12:52:28 AM
Edited by - GoofProg on July 30, 2000 12:53:11 AM
Edited by - GoofProg on July 30, 2000 12:52:28 AM
Edited by - GoofProg on July 30, 2000 12:53:11 AM
The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.
?Have a nice day!?
That''s right, when you have that ''typedef'' there, you''re not creating a variable that has a struct as its type, you''re creating the type itself. That''s what allows you to declare variables of that type at any point in your program. Without the typedef, you''re just creating a variable that has that struct as its type. If you try to use that variable as a data type later in your program, that''s where all those errors will come from. The ''typedef'' makes it a little nicer so you don''t have to type "struct [whatever]" every time you want to set up a variable of that type.
-Ironblayde
Aeon Software
-Ironblayde
Aeon Software
"Your superior intellect is no match for our puny weapons!"
struct foo{ // members go here}wodgen, duf; // these are structs of type foowodgen.member = 1;typedef struct widget{ //members in here}doodad, *lpwidget; // These are alternative names for a widgetdoodad flup; // flup is a widgetlpwidget nossler; // nossler is a pointer to a widget
does this clear it up? The bits at the end of a struct definition are structs of that type and the bits at the end of a typedef struct definition are different names for the same type. Removing the typedefs might make an error because the typedeffed name is being used, and it is not defined as a name, it is defined as a structure of that type, and so an error results.
------------------------------
#pragma twice
quote: Original post by furby100
struct foo{
// members go here}
wodgen, duf; // these are structs of type foowodgen.member = 1;
typedef struct widget{
//members in here}
doodad, *lpwidget; // These are alternative names for a widgetdoodad
flup; // flup is a widgetlpwidget nossler; // nossler is a pointer to a widget
does this clear it up? The bits at the end of a struct definition are structs of that type and the bits at the end of a typedef struct definition are different names for the same type. Removing the typedefs might make an error because the typedeffed name is being used, and it is not defined as a name, it is defined as a structure of that type, and so an error results.
------------------------------
#pragma twice
..i hope you dont name all your variables like that
Why not? I do
-Chris Bennett ("Insanity" of Dwarfsoft)
Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
-Chris Bennett ("Insanity" of Dwarfsoft)
Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement