I'm going to build an example game using playdate SDK on Windows.
I made a Visual Studio solution file with cmake command, referring the document .
When I "build the solution", my Visual Studio 2019 fails building and show the error:
Error C2375 'eventHandler': redefinition; different linkage hello_world C:\PlaydateSDK\C_API\Examples\Hello World\src\main.c 21
Is this a bug of main.c, or my fault missing some configuration?
This is due to the forward declaration of eventHandler in pd_api.h:
// main entry point defined in game code, called for the above events
int eventHandler(PlaydateAPI* playdate, PDSystemEvent event, uint32_t arg);
The examples all have
#ifdef _WINDLL
__declspec(dllexport)
#endif
in front of eventHandler, but not in pd_api.h.
If you add the above snippet to pd_api.h so it looks like this:
// main entry point defined in game code, called for the above events
#ifdef _WINDLL
__declspec(dllexport)
#endif
int eventHandler(PlaydateAPI* playdate, PDSystemEvent event, uint32_t arg);
Then it will compile fine.
P.S would you like me to open a thread on the bugs forum? I've noticed a few people have run into this.