Arithmetic on function address

M

Martin Dickopp

How would you propose to display the *value* of any variable ?
Not:
unsigned int i = 42; printf("%u\n%x\n", i, i);
The squiggles '4' '2' juxtaposed are a representation. "%u" means to
present the value in base-10 form. "%x" means to present it in base-16
form. You cannot say that one of the two things printed here is
"the value" and the other is merely "the representation". You cannot
say that they are both "the value", because they are different.

The terms "value" and "representation" (of types, which is obviously
what Dan meant) have well-defined meanings in C. If a program displays
the glyph associated with the character '4' followed by the glyph for
'2', it is displaying the *value* of `i'.

The short (and most likely not very accurate) definition of
"representation" is what you get when you access an object through a
pointer to `unsigned char'. For a full description, read section 6.2.6
of the standard.

Martin
 
D

Dan Pop

In said:
Not at all. EXIT_SUCCESS is required to make the caller aware of
the fact that "successful termination" occurred. The question of which
bits of data to set at what memory locations to achieve this is of course
implementation-defined, but that doesn't equate to non-portability.

You're missing the point. A platform may have many forms of SUCCESS
exit status, with different semantics that are important to the users
of that platform. The C standard doesn't tell us to which of them
EXIT_SUCCESS will be mapped, this *explicitly* left
implementation-defined. And if two implementations choose different
mappings, you have genuine non-portability.
Who said it wasn't?

Common sense: I have yet to see a poster saying that he is using a C99
compiler.
How would you propose to display the *value* of any variable ?

The distinction between value and its representation is clearly explained
in the C99 standard. Do yourself a favour and read it.

Dan
 

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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top