typedef int int_4
typedef int int_u8
typedef int_4
what's the difference between these three?
typedef int int_4
typedef int int_u8
typedef int_4
what's the difference between these three?
Are you real, or what? Do you ecpect to learn every aspect of a language through forums?
Sorry for being rash but i could not help it.
The first two statemenets declare, should someone put a ; before the newline , synonyms for the type int. although somewhat bad synonyms. The last statement is ignored as an empty definition, producing a useless type name in empty declaration compiler warning.
A typical example of ...cheap programming practices.Code:... goto johny_walker_red_label; johny_walker_blue_label: exit(-149$); johny_walker_red_label : exit( -22$);
I am sorry, I am just learning C here and wanted to ask questions... I read the book, but it was unclear to me to make it more meaningful maybe int_u8 should be an unsigned int right?? deriving from it's name
typedef is used to define an alias for a type. I think typedef stands for typedefinition.
If I wrote this statement:
I'm basically making an alias called "letter". You can use it just like a type: ex (char, int, float). In this case I'm making letter an alias for type char. Whenever you define a variable that is type letter ex "my_letter", you are actually defining a char. If I had made letter an int, it you would be defining an int.Code:typedef char letter; letter my_letter = 'a'; printf("my_letter = %c\n", my_letter);
[edit]And as far as int_u8: based on the int_4 naming convention, I would guess that int_u8 should be an unsigned long int on a 32 bit computer[/edit]
Last edited by Brad0407; 03-03-2008 at 09:11 PM. Reason: After reading Dave's post, I corrected mine.
Don't quote me on that... ...seriously
http://groups.google.com/group/comp....aa047e41b7df51
Now, the "typedef" keyword is highly misleading. The very name "typedef" makes it "obvious" that it "def"ines a "type" -- but it does not do so at all! All "typedef" does is make an "alias" -- an extra name -- for some existing type.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*