Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a pointer to a pointer to a function 8 byte?

I know a pointer to a function is 8 byte because of virtualization but why a pointer to a pointer to a function is 8 byte?

typedef void(*fun())();
sizeof(fun*); // returns 8 byte
like image 748
Marcin Król Avatar asked Mar 27 '26 18:03

Marcin Król


2 Answers

If you have a 64-bit system with 8-bit bytes (and it sounds like you do), probably all pointers will be 8 bytes in size. Virtualization doesn't have anything to do with it.

like image 79
Carl Norum Avatar answered Mar 31 '26 04:03

Carl Norum


It's because they're both pointers to memory addresses regardless of what kind of data they point to, and you're running on a 64-bit system

If memory addresses were say... 4 bytes, than it would be impossible to have more than 4GB of ram on your computer. there just wouldn't be enough different pointer values.

like image 21
Sam I am says Reinstate Monica Avatar answered Mar 31 '26 03:03

Sam I am says Reinstate Monica