-
July 15th, 2010, 02:37 AM
#1
Size of address on a machine is size of integer. True or false?
Size of address on a machine is size of integer. True or false?
-
July 15th, 2010, 02:41 AM
#2
Re: Size of address on a machine is size of integer. True or false?
-
July 15th, 2010, 02:44 AM
#3
Re: Size of address on a machine is size of integer. True or false?
Maybe, depends on the machine and the compiler.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
July 15th, 2010, 05:03 AM
#4
Re: Size of address on a machine is size of integer. True or false?
Originally Posted by forumuser11@gmail.com
Size of address on a machine is size of integer. True or false?
Absolutely false. Look at 16-bit MSDOS and the various C++ compilers that run on that system.
Regards,
Paul McKenzie
-
July 15th, 2010, 05:23 AM
#5
Re: Size of address on a machine is size of integer. True or false?
I once worked on an embedded 68000 system. The addresses were 32bit and so were the integers, so, not always false.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
July 15th, 2010, 07:13 AM
#6
Re: Size of address on a machine is size of integer. True or false?
Here is a helpful link that shows the number of bits for various integral types, along with the number of bits for a pointer on a 64-bit machine.
http://en.wikipedia.org/wiki/64-bit#...ge_data_models
The point is, that regardless of whether it is a 16-bit, 32-bit or 64-bit machine, you should not assume in your code that a pointer has the same number of bits as an integral type, sometimes it's true, sometimes its not. If you do make the assumption, then at the very least your code will not be portable.
-
July 15th, 2010, 08:27 AM
#7
Re: Size of address on a machine is size of integer. True or false?
false.
On modern machines ints are 4 bytes and addresses are 8. Only on old 32-bit machines are they the same size.
-
July 15th, 2010, 08:38 AM
#8
Re: Size of address on a machine is size of integer. True or false?
Originally Posted by ninja9578
Only on old 32-bit machines are they the same size.
Only if you believe that all C++ coding is done for PC's. There are an awful lot of (current) 32bit processors used in embedded applications out there. Think ARM for example.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
July 15th, 2010, 08:47 AM
#9
Re: Size of address on a machine is size of integer. True or false?
I'm aware of that, but judging by the question, I would assume that the OP is learning C++, and almost all learning is done on a PC. I've done plenty of embedded myself, and have had all sorts of weird sizes for words and addresses. I usually find with embedded is that ints are 32-bit and addresses are 16.
-
July 15th, 2010, 04:25 PM
#10
Re: Size of address on a machine is size of integer. True or false?
sizeof(size_t) should always equal sizeof(void*). Otherwise the standard doesn't guarantee anything other than sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).
-
July 15th, 2010, 05:27 PM
#11
Re: Size of address on a machine is size of integer. True or false?
Originally Posted by forumuser11@gmail.com
Size of address on a machine is size of integer. True or false?
Remember "define is"?
Sometimes? Always? What's your question?
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
July 15th, 2010, 08:46 PM
#12
Re: Size of address on a machine is size of integer. True or false?
Originally Posted by Speedo
Otherwise the standard doesn't guarantee anything other than sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long).
It also guarantees that sizeof(char) == 1, CHAR_BIT >= 8, and the various minimum ranges for the standard built-in integer types.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|