473,378 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 3903
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sunil Menon | last post by:
Dear All, A class having no member variables and only a method sizeof(object) will return 1byte in ANSI and two bytes in Unicode. I have the answer for this of how in works in ANSI. But I don't...
2
by: Xiangliang Meng | last post by:
Hi, all. What will we get from sizeof(a class without data members and virtual functions)? For example: class abnormity { public: string name() { return "abnormity"; }
19
by: Martin Pohlack | last post by:
Hi, I have a funtion which shall compute the amount for a later malloc. In this function I need the sizes of some struct members without having an instance or pointer of the struct. As...
9
by: M Welinder | last post by:
This doesn't work with any C compiler that I can find. They all report a syntax error: printf ("%d\n", (int)sizeof (char)(char)2); Now the question is "why?" "sizeof" and "(char)" have...
7
by: dam_fool_2003 | last post by:
#include<stdio.h> int main(void) { unsigned int a=20,b=50, c = sizeof b+a; printf("%d\n",c); return 0; } out put: 24
42
by: Christopher C. Stacy | last post by:
Some people say sizeof(type) and other say sizeof(variable). Why?
8
by: junky_fellow | last post by:
Consider the following piece of code: #include <stddef.h> int main (void) { int i, j=1; char c; printf("\nsize =%lu\n", sizeof(i+j));
90
by: pnreddy1976 | last post by:
Hi, How can we write a function, which functionality is similar to sizeof function any one send me source code Reddy
32
by: Abhishek Srivastava | last post by:
Hi, Somebody recently asked me to implement the sizeof operator, i.e. to write a function that accepts a parameter of any type, and without using the sizeof operator, should be able to return...
5
by: Francois Grieu | last post by:
Does this reliably cause a compile-time error when int is not 4 bytes ? enum { int_size_checked = 1/(sizeof(int)==4) }; Any better way to check the value of an expression involving sizeof...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.