Integer Length for Intel Core 2 Duo (MAC OSX)

AI Thread Summary
The discussion centers on determining whether an Intel Core 2 Duo machine running Mac OS X is 32-bit or 64-bit based on output from a C program. The output shows that the integer type is 32 bits, leading to confusion about the machine's architecture. It is clarified that an `int` is typically 32 bits even on a 64-bit system, while `long long` is 64 bits. The compiler settings are crucial, as the code may be generating 32-bit output instead of 64-bit, which can be adjusted with specific compile options. Overall, the expected sizes for other types like `float` and pointers are consistent with 64-bit architecture, but the compiler's configuration must be verified.
cjm2176
Messages
8
Reaction score
0
Hello all,

I am trying to determine if my machine is 64 bit or 32 bit, according to this site:

http://support.apple.com/kb/ht3696"

the Intel Core 2 Duo I am using is 64 bit, but when I run the following code

Code:
#include <stdio.h>

int main(int argc, char **argv)
{
  char c;
  int  i;
  float f;
  double d;
  long l;
  long long ll;
 
  printf("char %ld, int %ld, long %ld, long long %ld, float %ld, double %ld, pointers %ld\n",
  8*sizeof(c),
  8*sizeof(i),
  8*sizeof(l),
  8*sizeof(ll),
  8*sizeof(f),
  8*sizeof(d),
  8*sizeof(&c));
}

I get the output:

char 8, int 32, long 32, long long 64, float 32, double 64, pointers 32

If my machine is 64 bit should I be getting int 64 instead of int 32? If yes could this be a problem? I am using GNU compilers, i.e. gcc.

Thanks
cjm2176
 
Last edited by a moderator:
Technology news on Phys.org
No, int is 32 bits. long long int would be a 64 bit signed integer. or compile with the -m64 switch (or is it -arch x86_64 on mac? something like that)
 
Last edited:
Ok thanks, are the other types the expected length for 64 bit? such as float and pointer?
 
cjm2176 said:
Ok thanks, are the other types the expected length for 64 bit? such as float and pointer?
The code you showed has more to do with the code that the compiler generates than with the size of a register on your computer.

32 bits for a float is pretty standard and 64 bits for a double, which you didn't check. The fact that your compiler reports that a pointer is 32 bits makes me think that your compiler is generating 32-bit code.
 
I tested your source code on Windows XP X64, using Microsoft Visual Studio (2005) in 64 bit mode, the only difference is that the pointers are 64 bit. Check to see if your compiler has a 64 bit compile option. For Visual Studio, the project build configuration has to be set to x64 to get 64 bit mode.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top