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 6708595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:46:44+00:00 2026-05-26T07:46:44+00:00

The title is actually a bit misleading, but I wanted to keep it short.

  • 0

The title is actually a bit misleading, but I wanted to keep it short. I’ve read about why I should use size_t and I often found statements like this:

size_t is guaranteed to be able to express the maximum size of any object, including any array

I don’t really understand what that means. Is there some kind of cap on how much memory you can allocate at once and size_t is guaranteed to be large enough to count every byte in that memory block?

Follow-up question:
What determines how much memory can be allocated?

  • 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-26T07:46:44+00:00Added an answer on May 26, 2026 at 7:46 am

    Let’s say the biggest object your compiler/platform can have is 4 gb. size_t then is 32 bit. Now let’s say you recompile your program on a 64 bit platform able to support objects of size 2^43 – 1. size_t will be at least 43 bit long (but normally it will be 64 bit at this point). The point is that you only have to recompile the program. You don’t have to change all your ints to long (if int is 32 bit and long is 64 bit) or from int32_t to int64_t.
    (if you are asking yourself why 43 bit, let’s say that Windows Server 2008 R2 64bit doesn’t support objects of size 2^63 nor objects of size 2^62… It supports 8 TB of addressable space… So 43 bit!)

    Many programs written for Windows considered a pointer to be as much big as a DWORD (a 32 bit unsigned integer). These programs can’t be recompiled on 64 bit without rewriting large swats of code. Had they used DWORD_PTR (an unsigned value guaranteed to be as much big as necessary to contain a pointer) they wouldn’t have had this problem.

    The size_t “point” is the similar. but different!

    size_t isn’t guaranteed to be able to contain a pointer!!
    (the DWORD_PTR of Microsoft Windows is)

    This, in general, is illegal:

    void *p = ...
    size_t p2 = (size_t)p;
    

    For example, on the old DOS “platform”, the maximum size of an object was 64k, so size_t needed to be 16 bit BUT a far pointer needed to be at least 20 bit, because the 8086 had a memory space of 1 mb (in the end a far pointer was 16 + 16 bit, because the memory of an 8086 was segmented)

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

Sidebar

Related Questions

It's actually a bit more complicated than the title. I'm trying to figure out
I hope the title actually describes what I wanted to ask... I wrote a
The title may sound confusing but it actually isn't, I just didn't know how
it's a bit cheating, because there is actually two questions in the title. on
the question sounds a bit confusing, but it is actually straightforward. This is a
the question sounds a bit confusing, but it is actually straightforward. This is a
I know the title is a bit messy, but I don't know how to
OK, I admit that the title is a bit misleading. I'm braindead currently, so
OK, the question title is a bit crappy, but I didn't really know how
Hmm... Title is a bit of a mouthful, but I'm really not sure which

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.