lsalzman / enet

ENet reliable UDP networking library
MIT License
2.66k stars 667 forks source link

Move `extern "C"` below `#include`s in API header. #260

Closed adamwych closed 1 month ago

adamwych commented 1 month ago

Hello. This is a small change that helps in using ENet as a dependency in a Swift project.

Basically, the issue is that Swift does not support mixing C and C++ code when using interop, it has to use either C or C++, so if someone already has a C++ dependency in their project, Swift will try to import ENet as Objective-C++, but this will cause issues due to #includes.

This technically is a shortcoming of Swift, not specifically an issue with ENet, but the fix is very simple and from what I know shouldn't break anything for people using ENet from C/C++/other languages with interop.

lsalzman commented 1 month ago

The fix is a bit more involved then this. I took care of it with my own commit.