How to check if a void* pointer can be safely cast to something else?

前端 未结 6 2240
南旧
南旧 2020-12-19 08:32

Let\'s say I have this function, which is part of some gui toolkit:

typedef struct _My_Struct My_Struct;
/* struct ... */

void paint_handler( void* data )
{         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 08:49

    I know the question is 3 years old but here I go, How about using a simple global enum to distinguish where the function is called from. then you can switch between what type to cast the void pointer to.

提交回复
热议问题