Home > Articles > Programming > C/C++

  • Print
  • + Share This
From the author of Pointers and Pointers

Pointers and Pointers

The void* type represents a pointer to any kind of data. In most implementations, it can represent a pointer to anything. But the C standard doesn't allow casting between function pointers and data pointers. Most compilers support this as an automatically enabled extension, and won't warn you about it.

Unfortunately, some platforms really don't allow it. Some embedded systems use separate address spaces for code and data, or store them in different segments, accessed via different offset registers. Casting from one to another will result in something weird.

In some cases, these pointers are different sizes. For example, a number of 64-bit architectures only allow 32-bit addresses for instruction addresses, to help improve instruction density. An ABI for some of these platforms can define that function pointers are 32 bits, while data pointers are 64 bits. This is quite rare, but it happens occasionally.

  • + Share This
  • 🔖 Save To Your Account