sizeof(pointer)

I use VS2017 on a 64-bit Windows 10 system.

sizeof(*int) tells me 4bytes. But you need 8 bytes to address a 64-bit address. Then the pointer's size should also be 8bytes right? How is it 4bytes? Am I being dumb?
Maybe it's targeting 32-bit systems and needs some project twiddling to generate a true 64-bit image.
https://docs.microsoft.com/en-us/visualstudio/ide/visual-studio-ide-64-bit-support?view=vs-2017

How is it 4bytes?
sizeof(*int) is not a valid expression. What exactly is the sizeof about?

Something like this?
1
2
    int x;
    std::cout << "sizeof(&x)" << sizeof(&x)<<'\n';
sizeof(&x) = 8
1
2
3
4
	
        int* foo;
        int bar;
	cout << sizeof(foo) << '\n' << sizeof(&bar);

// Output
4
4


You were right salem c my compiler was set to build for Win32. I guess I forgot that you can run 32-bit applications on 64-bit systems..

It shows 8 bytes like expected when I set it to x64 ;)
Topic archived. No new replies allowed.