Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's interesting to know. Is there no general data type that's guaranteed to hold a function pointer?


Only function pointer types. An indirect function call on some architecture, for example, could require that when one makes an indirect call one sets up several registers in addition to jumping to a particular location in memory, and none of the registers that need to be set up can be derived from the jump target. So in practice your function pointers would need to actually be structures containing those register values and the jump target. Or you might need to pass around a tuple of target and calling convention, although the C standard limits the ways you could implement that (namely by requiring that function pointers cast to and from other function pointer types will compare as equal, and will still work when they are cast to the correct type.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: