what does this mean?/

This is a discussion on what does this mean?/ within the C Programming forums, part of the General Programming Boards category; typedef int int_4 typedef int int_u8 typedef int_4 what's the difference between these three?...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    what does this mean?/

    typedef int int_4
    typedef int int_u8
    typedef int_4

    what's the difference between these three?

  2. #2
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    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.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    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

  4. #4
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    typedef is used to define an alias for a type. I think typedef stands for typedefinition.
    If I wrote this statement:
    Code:
    typedef char letter;
    letter my_letter = 'a';
    printf("my_letter = %c\n", my_letter);
    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.

    [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

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    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.*

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21