Passing a shared_ptr through a C interface that takes void *
问题 I have a C++ project that uses SDL, in particular SDL Events. I would like to use the event system for incoming network messages just as it is used for UI events. I can define a new event type and attach some arbitrary data (see this example). This is what I would do if I was using ordinary pointers: Uint32 message_event_type = SDL_RegisterEvents(1); /* In the main event loop */ while (SDL_Poll(&evt)) { if (evt.type == message_event_type) { Message *msg = evt.user.data1; handle_message(msg);