So I've read a lot of related posts on SO and elsewhere such as:
http://stackoverflow.com/questions/399003/is-the-sizeofsome-pointer-always-equal-to-four
It makes total sense to me that on a 32-bit system I would expect 4-byte pointers and on a 64-bit system I would expect 8-byte pointers. So I'm running this code:
int main()
{
cout << "sizeof(int) = " << sizeof(int) << endl;
cout << "sizeof(void*) = " << sizeof(void*) << endl;
}
And this is the corresponding output:
sizeof(int) = 4
sizeof(void*) = 8
I'm running in 32-bit mode on Mac OS X 10.6.1. Here's the output of "uname -a":
Darwin brent-nashs-macbook.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386 i386
Here's the version of g++ I'm running (default that came with the system):
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646)
So I realize that the sizes of pointers are not guaranteed from system to system and they're completely dependent on compiler and architecture, but does this result strike anyone else as illogical? Is this just an idiosyncrasy of Mac OS X 10.6 or my setup? Or is there a good reason I'm seeing pointers of this size?
==================================================
Post-Answer Addition
Extra details for anyone who wants them...
I was originally compiling with this command line:
g++ -Wall -o TestClass1 TestClass1.cpp
And it generated this output:
sizeof(int) = 4
sizeof(void*) = 8
After the suggestion below, I changed my command line to this:
g++ -Wall -o TestClass1 -arch i386 TestClass1.cpp
And the output changes to this:
sizeof(int) = 4
sizeof(void*) = 4