Compiler Error C2375 on Visual Studio building "Hello World" C_API example

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?

I don't have access to the windows toolchain right now but I would suspect there is a configuration issue for the project.

Can you say which example you try to build and what output you get with cmake?

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.

4 Likes

Sorry for the less detail. The sample is "Hello World." The screenshot of the output is here. (Some folders might be generated by Visual Studio.)