Re: from 32 to 64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/31/2009 03:12 PM, Patrick Dupre wrote:
> Hello,
>
> I do observe abnormal results with my applications
>
> Moving from a 32 to 64 bits architecture, using, c, C++, perl, is
> they something that I should be aware of ? like size of the
> float, integer ?
>
> Thank.
>
In the C and C++ languages as implemented by GCC on Linux and other Unix
systems use a policy called LP64 for 64-bit systems:
char is 8 bits, short is 16 bits, int is 32 bits (always on 32 and 64
bit systems using LP64).
long is 64-bits (on 64-bit systems, 32-bits on 32-bit systems)
float is always 32-bits
double is always 64-bits
pointers are 64-bits on 64-bit systems, 32-bits on 32-bit systems.

There are a number of programming gothchas that have been well documented.
here is a pointer to some documents on HP (part of which I wrote)
http://docs.hp.com/en/5966-9844/ch03s02.html

But, beware, while Linux and Unix systems have adopted LP64 pretty
universally, other systems use LLP64 and ILP64.

The bottom line when writing programs is not to assume anything. Use
types like int32_t, or int64_t for signed integrals, use size_t for
sizes. That will generally be 32-bit on 32-bit systems and 64-bits on
64-bit systems.

-- 
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix
PGP key id: 537C5846
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux