Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 416781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:30:52+00:00 2026-05-12T18:30:52+00:00

I am experimenting with my first cross-platform application that needs to run on Linux

  • 0

I am experimenting with my first cross-platform application that needs to run on Linux Redhat 5.3 and also on Windows XP/Vista/7.

As some OSes will run x86 or 64, I am wondering about what data types to declare.

I don’t want to use any libraries to achieve cross-platform portability; I would like to experiment by myself first.

If I need a int, should I declare int32 or int64 or just int?

If I was to compile on a 64-bit OS and use an int32 then the would the data be truncated to a 32 bit value so I would lose some data?

I am wondering how I should declare if I run on different OSes with different architectures.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:30:53+00:00Added an answer on May 12, 2026 at 6:30 pm

    In many 64-bit OSes (such as 64-bit Linux), ints are still only 32 bits wide; only longs and pointers are 64 bits wide. This is referred to as an LP64 data model. The reason for this is that in many cases, an int does not need more range than is provided by 32 bits, and using 64 bits would only waste memory. Under 64-bit Windows, evens longs are 32-bit (for compatibility with 32-bit Windows), and only long longs are 64-bit; this is referred to as an LLP64 data model.

    If your application is going to be running on 32-bit as well as 64-bit operating systems, then the range of a 32-bit integer is obviously sufficient — otherwise, you would be in trouble on the 32-bit OS. So just go ahead and use ints in those cases. If you can identify cases where you need the range of a 64-bit integer, use an int64_t (defined in stdint.h) explicitly. To make sure the binary data formats you write to disk are compatible across platforms, use int32_t and int64_t explicitly in those places… but also be aware of potential endianness issues.

    Finally, when writing 64-bit code, be aware that pointers cannot be converted to ints in a LP64 data model — so use uintptr_t instead.

    If you code cleanly, 32-bit/64-bit portability should be almost a non-issue — there’s not really much more you need to be aware of than what I’ve written above. Portability between Windows and Linux will generate much greater issues that portability between 32-bit and 64-bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.