Type of variable

K

Keith Thompson

*Shrug* If it is designed to generate code for such a restricted system,
I would consider it poor quality of service if it didn't check, _even_
if you were using a Frankenstein implementation. After all, only 4k of
stack, all by itself, screams "specialist application". It didn't 30
years ago, but today?

How can it check?

It can't check at compile time because the information doesn't exist
(the same code might run on one system with 4k of stack and another
with 32k of stack), and it can't check at run time because, on such
a restricted system, stack overflow checks are probably going to
be unacceptably expensive.

A configurable warning would be nice, but that's a QoI issue.
 
R

Richard Bos

Keith Thompson said:
How can it check?

Frankly, that's its problem.
It can't check at compile time because the information doesn't exist
(the same code might run on one system with 4k of stack and another
with 32k of stack), and it can't check at run time because, on such
a restricted system, stack overflow checks are probably going to
be unacceptably expensive.

A configurable warning would be nice, but that's a QoI issue.

Which, if you look up ^ there, was exactly my point. I find an
implementation for such specialised systems that cannot deal with such
specialised requirements not acceptable QoI, and do not expect
programmers to have to take them into account.

Richard
 
J

James Kuyper

Old said:
Huh? Types are all known at compile-time in C.
They don't change at runtime..

The question makes more sense in C++, where a pointer or reference to a
base class might actually refer an object of a derived class, and it
would be desirable to know what the derived type is; C++ does provide a
mechanism for do so.

In C, the closest equivalent to that situation is the use of a void*
pointer. The type of the object actually pointed at by such a pointer is
generally not known at compile-time, and yes, it can change.

C provides no mechanism for determining the type of the object pointed
at by a void* pointer, and I wouldn't recommend adding such a feature to
the language - it's not quite impossible to implement, but the costs of
doing so would be high. However, I can understand why someone might wish
is were available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top