Thread: what are __u32, __u16, __u8 ?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    32

    what are __u32, __u16, __u8 ?

    Dear All,

    what are __u32, __u16, __u8 ?


    Code:
    typedef struct a
    {
    	__u32 ival;
    		__u16 ivar;
    }b;
    
    
    b *c;
    c->ival=3;
    how to print ival/ivar ? which type they are ?



    Thanks in advance ...

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    this is unsigned integer type with 8,16,32 bits in it...
    you can print them all using %u format

    PS. on the 16-bit compiler you may need %lu for the last one as it will be probably typedef of unsigned long...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    32
    below code showing errors

    __u32 undeclared
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
    
    __u32 a;
    a=12;
    printf("__u32 a =&#37;lu", a);
    
    return 0;
    }

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    below code showing errors
    so you do not have these types defined...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    Are you needing to work with the

    asm/types.h

    Header file? As I believe those types are defined within.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Since the names begin with underscores, it means they're specific to whatever system you're using.
    So unless you give us more detail, we can't help.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    32
    Thanks for all,

    These are all system specific and defined in asm/types.h


    thanks ...

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    1
    In some gcc compilers the header file reqd. may be <sys/types.h>

  9. #9
    Registered User
    Join Date
    Sep 2007
    Posts
    1,012
    As of C99 there are standard fixed width types. If you include stdint.h then you get int8_t, uint8_t, int16_t, uint16_t, etc. These have at least a fighting chance of being portable, since they're standard C, even if it is the newer, less-implemented standard. I'd recommend using stdint.h if you can, since it's less system-specific than types like __u8.

    Of course these types need not exist on systems without the "proper" standard types (say a system with 9-bit bytes), but that would be true for __u8, etc. as well.

Popular pages Recent additions subscribe to a feed