comp.lang.ada
 help / color / mirror / Atom feed
From: Chris Engebretson <e8ag@sdsumus.sdstate.edu>
Subject: Re: Help you C++ Debuggers!
Date: 1997/01/21
Date: 1997-01-21T00:00:00+00:00	[thread overview]
Message-ID: <32E5982A.3A7@sdsumus.sdstate.edu> (raw)
In-Reply-To: 1997Jan20.144447.5581@news


David Emery wrote:

> >C does not support objects greater than 32767 bytes portably.
> 
> Huh?  Where in the C Language Definition is this specified?

Tanmoy's correct.  The size of an object is measured by the sizeof
operator, which yields type size_t.  More specifically, the
Standard defines size_t (in <stddef.h>) to be a constant of
unsigned integral type.  Beyond that, the Standard also says:

    2.2.4.1 Translation limits

    The implementation shall be able to translate and execute at least
    one program that contains at least one instance of every one of the
    following limits:

    [ snip unrelated limits ]

    * 32767 bytes in an object (in a hosted environment only) 

Seems pretty clear-cut to me.  :-)

It's helpful not to confuse pointers with objects; if I write

    char *ptr;
    ptr = malloc (8 * 1024 * 1024);

I now have a pointer to an eight-megabyte region of allocated
memory (provided, of course, that the allocation succeeds.)  But
despite what noted fools such as Herbert Schildt would have you
believe, sizeof (ptr) == sizeof (char*), not (8 * 1024 * 1024).
In other words, the size of a pointer is just that: the size of
the pointer.  It isn't the size of the region it points to.

On the other hand, if you write

    char array[8 * 1024 * 1024];

you may very well run into problems, depending on the definition
of size_t.  Since declaring an automatic array of this size is
completely ridiculous, though, I'd hardly consider this a fault.

> Given the
> limitations of Intel 80x86 16-bit architectures, I could understand
> this being a possible limitation of poor PC C compilers.  But I can't
> see this as being a shortcoming of the C -language-. 
> As a programming language, C has lots of shortcomings, but this isn't
> one (any) of them...

Whether or not it's a shortcoming is a matter of opinion, but the
fact remains that it's a part of the language.

PS: Also note Tanmoy's phrase "portably"; 32767 bytes is all that
the Standard guarantees, although you may be able to "get away 
with" a larger object.  But again, in cases where an object larger
than this is needed, it only makes sense to use an allocated
region, as opposed to an automatic/static object.  And at least
within the realm of c.l.c, this "limitation" should be respected.

Regards,

-- 
Chris Engebretson -- e8ag@sdsumus.sdstate.edu
Linux -- The choice of a GNU generation!
I'm at home, so what my employer thinks is irrelevant.




  parent reply	other threads:[~1997-01-21  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-16  0:00 Help you C++ Debuggers! Macarthur Drake
1997-01-19  0:00 ` Tore Lund
     [not found]   ` <32E4EC1B.748E@acm.org>
1997-01-23  0:00     ` Tansel Ersavas
1997-01-23  0:00       ` Danette & Murray Root
1997-01-23  0:00       ` Tansel Ersavas
     [not found]       ` <01bc093e$9992fa60$966d6f9e@Defualt.DVRD.CDC.GOV>
1997-01-24  0:00         ` Tore Lund
1997-01-25  0:00         ` Lawrence Kirby
1997-01-20  0:00 ` Gautier
1997-01-20  0:00   ` Tanmoy Bhattacharya
1997-01-21  0:00   ` Chris Engebretson
1997-01-21  0:00   ` Chris Engebretson [this message]
1997-01-21  0:00   ` Ole-Hjalmar Kristensen FOU.TD/DELAB
1997-01-21  0:00     ` Bradley A. Burns
1997-01-21  0:00   ` David Emery
1997-01-22  0:00   ` David Emery
1997-01-22  0:00   ` Michael Chapman
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox