+ Reply to Thread
Results 1 to 2 of 2

Thread: What is the size of int and pointer on 64 bit operating system and compiler?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    48

    What is the size of int and pointer on 64 bit operating system and compiler?

    Hi all,

    What is the size of int and pointer on 64 bit operating system and compiler?

    Regards

  2. #2
    Hi,

    It is compiler who decides the size of int.

    Pointer size depends on the installed operating system whether you are running on 32bit platform or 64bit platform.

    Below example depicts this:

    Code:
    void UsePointers()
    {
    	//On 32bit or 64bit platform:
    	//sizeof(int) is 4 bytes.
    	int nSize32 = sizeof(int) ;
    
    	//On 32bit Operating System:
    	//a. pPointer can be like this 0x00322650
    
    	//On 64bit Operating System:
    	//a. pPointer can be like this 0x0000000000322650
    	int *pPointer = new int(32) ;
    
    	//On 32bit Operating System:
    	//a. sizeof(pPointer) is 4 bytes, which is equivalent 32bit
    
    	//On 64bit Operating System:
    	//a. sizeof(pPointer) is 8 bytes, which is equivalent 64bit
    	int nPointeSize = sizeof(pPointer) ;
    
    	delete pPointer ;
    }
    Note:
    a. Please note that above example's results are based on MS VS 2005 VC++.
    b. Using cross compilers user can create binaries for 64bit application on 32bit operating system and vice-versa.
    c. So size of pointer on 32bit platform is 4 bytes and on 64bit platform it is 8 bytes.

    Thanks.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts