I'd like to make a tool that automatically wraps C libraries in:
#ifdef __cplusplus
extern "C" {
#endif
But I'm confused by what exactly needs to be wrapped with extern "C", and what needn't be. Only functions? What about any (shock-horror) global variables? Anything else?
If I write a script that just finds all functions and wraps them with extern "C", is that enough?
And finally: if the library already wrapped its functions with extern "C" and then they're wrapped again, can I trust that nothing bad happens and it'll still work fine, or do I need to explicitly check for this?