Tuesday, 15 March 2011

c++ - Casting "pointer to data" to "pointer to function" -


As In the data from the indicator to indicators work Is not allowed in C89, C99, what about C ++?

short answer: Implementation is not necessary to support such artists.

It may allow a reinterpret_cast subject to certain rules (essentially: to change the object pointer and return the original pointers).

standard, [expr.reinterpret.cast] / 8:

Converting function pointer to object pointer type or vice versa is conditionally supported. The meaning of such a conversion is implementation-defined, except that if an implementation supports conversions in both directions, then one type of one type can be converted to another type and back, possibly with various CV-qualifications , The original indicator will receive the price. / P>

Non-embedded implementations generally allow the purposes of dynamic linking (like dlsym () ). Strictly speaking, however, it is not necessary to work.


No comments:

Post a Comment