Mail Archives: djgpp/2004/03/04/16:31:10
On Thu, 4 Mar 2004 12:32:51 +0200 in comp.os.msdos.djgpp, "Tõnu Aas"
<tonu AT ids DOT ee> wrote:
>> Portable assumptions are: char holds at least 8 bits, int at least 16,
>> long at least 32: pick the appropriate size for the range of integers
>> you have to deal with. Avoid C99 stdint.h if you want to be portable
>> to most existing implementations.
>
>You can create your own stdint.h if "existing implementations" havent one.
>Its much easier than using #ifdefs all over you code to maintain
>portability.
Are you trying to imply the types defined in stdint.h are more
portable than char, int, long?
If you use the stdint.h definitions, maybe you should include the
header with your code to ensure portability.
That saves others the trouble of making up their own, or editing your
types back to the base t0ypes.
Do you really see an advantage to using int_least16_t or int_fast32_t
where int and long would do?
Or do you just want to be first on the block who can claim they
littered their code with extraneous types from stdint.h?
AFAICT stdint.h is intended for use in circumstances where particular
integer characteristics are required for particular reasons in
portable code.
By using the new integer types, you are raising flags saying these
variables are special, and you may cause the compiler to generate
extra code to ensure that standards requirements are met.
OTOH I expect most compilers to just treat them the same as the base
types, so in that case what have you gained in terms of code clarity,
efficiency, and portability?
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian DOT Inglis AT CSi DOT com (Brian dot Inglis at SystematicSw dot ab dot ca)
fake address use address above to reply
- Raw text -