Integer Length for Intel Core 2 Duo (MAC OSX)

Click For Summary

Discussion Overview

The discussion revolves around determining the bit architecture of a machine running an Intel Core 2 Duo processor on Mac OSX, specifically focusing on the output of a C program that prints the sizes of various data types. Participants explore the implications of the output regarding the machine's architecture and compiler settings.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant questions whether the output of the program indicates a 32-bit architecture, as the int type is reported as 32 bits despite the machine being 64-bit capable.
  • Another participant clarifies that the int type is typically 32 bits, while long long int is a 64-bit signed integer, suggesting the use of specific compiler flags to enable 64-bit compilation.
  • There is a query about whether the sizes of float and pointer types are as expected for a 64-bit architecture, with a suggestion that the output may reflect the compiler's code generation rather than the machine's register size.
  • A participant shares their experience testing similar code on a different operating system, noting that pointers are 64 bits in that environment and advising to check for 64-bit compile options in the compiler settings.

Areas of Agreement / Disagreement

Participants generally agree on the size of the int type being 32 bits, but there is uncertainty regarding the implications of the output for the machine's architecture and the compiler's configuration. Multiple views on the expected sizes of other data types and the effects of compiler settings remain unresolved.

Contextual Notes

Limitations include the dependence on specific compiler settings and the potential for variations in data type sizes across different platforms and compilers.

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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 7 ·
Replies
7
Views
76K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 49 ·
2
Replies
49
Views
12K