From: Herbert Poetzl <herbert@13thfloor.at>
To: Ribamar Santarosa de Sousa <ribamar.sousa@ic.unicamp.br>
Cc: Brian Raiter <breadbox@muppetlabs.com>, linux-assembly@vger.kernel.org
Subject: Re: newbie question about integers size/portabilty.
Date: Wed, 29 Dec 2004 02:31:11 +0100 [thread overview]
Message-ID: <20041229013110.GD22398@mail.13thfloor.at> (raw)
In-Reply-To: <20041229010558.GB28029@ic.unicamp.br>
On Tue, Dec 28, 2004 at 11:05:58PM -0200, Ribamar Santarosa de Sousa wrote:
> >
> > Which is exactly why you need to use code to determine the sizes.
> > Documentation won't help because the sizes are free to change over
> > time, with new versions of the OS and/or the compiler.
> >
>
> We're talking about 2 differents things...
> *yes, i need the codes to warranty portability in timeline (you meant
> this, i didn't meant this)
> *i don't have the machine the code was written for the first
> time, so i don't know what authors meant when defining a structure
> having an int member: 16, 32, 64 bits? code doesn't help in this case (i
> suppose :).
> ...But don't care about this...
>
> >
> > Using the types defined in <linux/types.h> will make your code
> > unportable. They aren't even guaranteed to be present in future
> > versions of Linux.
> >
>
> ... living and learning... i didn't know this... i thought this types
> are defined for ensure i will have a unsigned 16 bit whenever i need a
> unsigned 16 bit structure...
yes, that is exactly the purpose of those types
(as is with C99 stdint.h types like uint16_t
and friends)
> > If you need a type that is at least 16 bits in size, use short or
> > int. If you need a type that is exactly 16 bits in size (no more or
> > less), then use conditional compilation with the macros in <limits.h>.
> > For example:
> >
> > #if USHRT_MAX == 0xFFFF
> > typedef unsigned short u16;
> > #elif UINT_MAX == 0xFFFF
> > typedef unsigned int u16;
> > #else
> > #error "Platform lacks an integer type that is exactly 16 bits."
> > #endif
>
> i will use this... thanks...
if you are coding for the linux-kernel, then
I would use the __u/sXX or u/sXX types ...
best,
Herbert
> > If you don't care about portability, then why bring this up in the
> > first place?
> >
>
> i do care!
>
> Thanks,
> Riba
>
> > b
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2004-12-29 1:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-28 12:29 newbie question about integers size/portabilty Ribamar Santarosa de Sousa
2004-12-28 13:35 ` Richard Cooper
2004-12-28 15:20 ` Ribamar Santarosa de Sousa
2004-12-30 9:10 ` Frederic Marmond
2004-12-28 22:38 ` Brian Raiter
2004-12-28 23:52 ` Ribamar Santarosa de Sousa
2004-12-29 0:17 ` Brian Raiter
2004-12-29 1:05 ` Ribamar Santarosa de Sousa
2004-12-29 1:31 ` Herbert Poetzl [this message]
2004-12-29 7:21 ` OT: " Richard Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041229013110.GD22398@mail.13thfloor.at \
--to=herbert@13thfloor.at \
--cc=breadbox@muppetlabs.com \
--cc=linux-assembly@vger.kernel.org \
--cc=ribamar.sousa@ic.unicamp.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.