what are __u32, __u16, __u8 ?

This is a discussion on what are __u32, __u16, __u8 ? within the C Programming forums, part of the General Programming Boards category; Dear All, what are __u32, __u16, __u8 ? Code: typedef struct a { __u32 ival; __u16 ivar; }b; b *c; ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    below code showing errors
    so you do not have these types defined...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    32,834
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    993
    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

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