468,491 Members | 1,991 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

Sizeof int

Hi,

Is there a way to change the sizeof int type? Is it posible to make it
return 3 or 5 by changing some header file in the compiler?

Thanks in advance.

Jul 22 '06
56 3464
Tak-Shing Chan wrote:
On Sun, 23 Jul 2006, Mark McIntyre wrote:
>On Sun, 23 Jul 2006 20:05:55 +0100, in comp.lang.c , Tak-Shing Chan
<t.****@gold.ac.ukwrote:
>>On Sun, 23 Jul 2006, Mark McIntyre wrote:

What do you mean by ``C as such''? All I am saying is that
C does have a ``concept'' of word length, even though the
behaviour of the abstract machine does not depend on it.

I disagree. The very para you quote is a reference to a different
standard, it does NOT refer to any feature of C.

<extreme analogy>
You could as well claim that C has a concept of ISO, because its
mentioned on several pages.
</end>

Your analogy is broken. The paragraph I quoted refers to a
normative reference of the standard. According to the standard:

``The following normative documents contain provisions
which, through reference in this text, constitute provisions of
this International Standard'' (ISO/IEC 9899:1999, 2 para. 1).

The standard continues: ``ISO 60559:1989, Binary
floating-point arithmetic for microprocessor systems (previously
designated IEC 559:1989)'' (ISO/IEC 9899:1999, 2 para. 8).

Then we have, in Annex F, an explicit reference to
ISO 60559:1989, making it a provision of C as well.
Surely, a 'word' is that amount of information the cpu can get from
memory in a single access. It is usually (not always) the width of the
accumulator.

The Intel family of cpu's is interesting. The 8080 and 8085 has
eight-bit words and eight-bit accumulators. The 8086 has 16-bit word and
accumulator. The 8088 has 8-bit word and 16-bit accumulator.

The 80386 and 80486 have 32-bit word and accumulator. The 80586
(Pentium) has 32-bit accumulator and 64-bit memory word.

There are C implementations for each of these processors. None of them
require or even allow the C programmer to know the width of the memory
word nor that of the accumulator.

I realize that accumulator may not be defined in the C standard, but all
our machines have at lease one. :-)

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Jul 24 '06 #51
wr********@gmail.com wrote:
>
Hi,

Is there a way to change the sizeof int type? Is it posible to make it
return 3 or 5 by changing some header file in the compiler?
If the compiler supports it, yes. (However, how this is done is not
topical to clc. You would need to check the documentation for the
compiler on how to do this.) If the compiler doesn't support it, then
there is nothing you can do (short of using, or writing, a different
compiler) do get 3 or 5 byte ints.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Jul 24 '06 #52
Joe Wright <jo********@comcast.netwrites:
Surely, a 'word' is that amount of information the cpu can get from
memory in a single access. It is usually (not always) the width of the
accumulator.
I don't think there's any general agreement on how to define the
"word size" of a machine.
--
"...what folly I commit, I dedicate to you."
--William Shakespeare, _Troilus and Cressida_
Jul 24 '06 #53
On Mon, 24 Jul 2006 00:53:03 +0100, in comp.lang.c , Tak-Shing Chan
<t.****@gold.ac.ukwrote:
>On Sun, 23 Jul 2006, Mark McIntyre wrote:
><extreme analogy>
You could as well claim that C has a concept of ISO, because its
mentioned on several pages.
</end>

Your analogy is broken.
Nope.
>The paragraph I quoted refers to a
normative reference of the standard.
So what? ISO gets mentioned in normative sections.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 24 '06 #54
On Mon, 24 Jul 2006, Mark McIntyre wrote:
On Mon, 24 Jul 2006 00:53:03 +0100, in comp.lang.c , Tak-Shing Chan
<t.****@gold.ac.ukwrote:
>On Sun, 23 Jul 2006, Mark McIntyre wrote:
>><extreme analogy>
You could as well claim that C has a concept of ISO, because its
mentioned on several pages.
</end>

Your analogy is broken.

Nope.
>The paragraph I quoted refers to a
normative reference of the standard.

So what? ISO gets mentioned in normative sections.
There are no normative references for ``ISO'' in the entire
C standard. See clause 2 for the list of normative references.

Tak-Shing
Jul 24 '06 #55
On Tue, 25 Jul 2006 00:30:21 +0100, in comp.lang.c , Tak-Shing Chan
<t.****@gold.ac.ukwrote:
>
There are no normative references for ``ISO'' in the entire
C standard. See clause 2 for the list of normative references.
*shrug*.

You're wrong, youre too stubborn to admit it. I can live with that.
EOT
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 25 '06 #56
On Tue, 25 Jul 2006, Mark McIntyre wrote:
On Tue, 25 Jul 2006 00:30:21 +0100, in comp.lang.c , Tak-Shing Chan
<t.****@gold.ac.ukwrote:
>>
There are no normative references for ``ISO'' in the entire
C standard. See clause 2 for the list of normative references.

*shrug*.

You're wrong, youre too stubborn to admit it. I can live with that.
EOT
On the contrary, my point is fully supported by ISO/IEC
9899:1999 (E).

Are you disagreeing with the C standard? Are you saying
that the C standard is wrong?

Tak-Shing
Jul 25 '06 #57

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sunil Menon | last post: by
19 posts views Thread by Martin Pohlack | last post: by
9 posts views Thread by M Welinder | last post: by
7 posts views Thread by dam_fool_2003 | last post: by
42 posts views Thread by Christopher C. Stacy | last post: by
8 posts views Thread by junky_fellow | last post: by
90 posts views Thread by pnreddy1976 | last post: by
32 posts views Thread by Abhishek Srivastava | last post: by
5 posts views Thread by Francois Grieu | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.