C99 and linux types - Linux

This is a discussion on C99 and linux types - Linux ; Hello, I don't quite understand how it's decided what types to use, C99 (uint32_t etc.) or linux defines (linux/types.h). What's the proper way to handle this dilemma? With best regards, Roman Mashak. E-mail: mrv@tusur.ru...

+ Reply to Thread
Results 1 to 6 of 6

Thread: C99 and linux types

  1. C99 and linux types

    Hello,

    I don't quite understand how it's decided what types to use, C99 (uint32_t
    etc.) or linux defines (linux/types.h). What's the proper way to handle this
    dilemma?

    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



  2. Re: C99 and linux types

    Roman Mashak wrote:
    > I don't quite understand how it's decided what types to use, C99
    > (uint32_t etc.) or linux defines (linux/types.h). What's the proper
    > way to handle this dilemma?


    Depends. The explicitly sized types in the Linux headers have been around
    longer than that the C99 standard has been implemented; BSD also had their
    flavour (u_int32_t or somesuch). For Linux code (code for Linux
    specifically, not code just running under Linux!) I'd use its own types,
    because those are typically also the ones used for declarations of
    interfaces.

    For portable code, I'd use the C99 ones. Even on legacy-systems where this
    header is not (yet) supported or in C++ it can be emulated trivially,
    while the benefit of using a standardised way to get a n-bit integer is
    significant.

    In other cases, I wouldn't use either, e.g. because I don't know the
    correct size. Don't fall for the same assumption like those that believe
    that a 'long' is 32 bit!

    > E-mail: xxx@xxxxx.xx


    Irrelevant, asked on the Usenet, answered on the Usenet.

    Uli


  3. Re: C99 and linux types

    Erik de Castro Lopo wrote:

    > Roman Mashak wrote:
    >
    >> Hello,
    >>
    >> I don't quite understand how it's decided what types to use, C99
    >> (uint32_t etc.) or linux defines (linux/types.h). What's the proper way
    >> to handle this dilemma?

    >
    > Use where is exists and fall back to something else
    > (maybe ) where it doesn't.


    Unless you are writing Linux kernel code where you should probably
    be using .

    Erik
    --
    +-----------------------------------------------------------+
    Erik de Castro Lopo
    +-----------------------------------------------------------+
    "Indeed, I am impressed that Google runs an 8,000 node Linux
    cluster, 5 data centers, an extensive network, and a rapidly
    evolving application all with a staff of 12."
    -- http://research.microsoft.com/~gray/...FAAMs_HPTS.doc

  4. Re: C99 and linux types

    Roman Mashak wrote:

    > Hello,
    >
    > I don't quite understand how it's decided what types to use, C99 (uint32_t
    > etc.) or linux defines (linux/types.h). What's the proper way to handle
    > this dilemma?


    Use where is exists and fall back to something else
    (maybe ) where it doesn't.

    Erik
    --
    +-----------------------------------------------------------+
    Erik de Castro Lopo
    +-----------------------------------------------------------+
    "Anyone who considers arithmetical methods of producing random
    digits is, of course, in a state of sin." - John Von Neumann (1951)

  5. Re: C99 and linux types

    Erik de Castro Lopo writes:
    > Roman Mashak wrote:
    >> Hello,
    >>
    >> I don't quite understand how it's decided what types to use, C99 (uint32_t
    >> etc.) or linux defines (linux/types.h). What's the proper way to handle
    >> this dilemma?

    >
    > Use where is exists and fall back to something else
    > (maybe ) where it doesn't.


    For UNIX(*) and similar systems, the 'portable' way would be (as far
    as I know) to include intypes.h (which, for instance, exists on
    Solaris 8, where stdint.h doesn't).


  6. Re: C99 and linux types

    Hello, Rainer!
    You wrote on Mon, 08 Jan 2007 11:08:38 +0100:

    ??>>> I don't quite understand how it's decided what types to use, C99
    ??>>> (uint32_t etc.) or linux defines (linux/types.h). What's the proper
    ??>>> way to handle this dilemma?
    ??>>
    ??>> Use where is exists and fall back to something else
    ??>> (maybe ) where it doesn't.

    Thanks to everyone, it's more clear to me now.

    With best regards, Roman Mashak. E-mail: mrv@tusur.ru



+ Reply to Thread