Issues getting mixed C/Lua examples running

I'm running CLion on Windows 10 and trying to get the C_API examples working. The pure C examples (Sprite Game, Hello World) have worked without issue. I can build, run, and breakpoint using the simulator. The mixed C/LUA examples (Array, 3D Library, Exposure) on the other hand do not run.

The C code appears to either not get compiled, included, or executed. When the LUA code calls into a function that the C code should have registered the example will crash with an error indicating the referenced value is nil.

Load failed: main.lua:6: attempt to index a nil value (global 'array')
stack traceback:
	main.lua:6: in main chunk

Debugging seems to confirm this. In the pure C examples breakpoints in the eventHandler function work as expected, halting the game until I allow it to continue. In the mixed C/LUA examples breakpoints in the eventHandler function are never hit. I even intentionally threw in some bad code that would crash and nothing changed.

Are mixed C/LUA projects not supported on Windows? Pure C/LUA projects build and run fine. Only mixed projects appear to have this issue.

Thanks for the details.

Strangely the same problem as the previous thread Bump Mapping Prototype (Real device test required) - #2 by daprice

1 Like

I think this looks similar to the problem someone is having with Playbox2d (port of box2d lite physics engine to C and Playdate SDK). Basically the C code never gets registered it seems.

Are you sure that registerArray(pd); gets called at all? I don't have a Windows machine to test this on but the eventHandler seems to have this in from of it:

#ifdef _WINDLL
__declspec(dllexport)
#endif

Maybe _WINDLL is not defined?

As far as I can tell it is not. My breakpoints into the function don't hit and intentionally throwing bad code into the function does nothing. Both of these do work in Sprite Game and other pure C example projects.

I just noticed this, the __declspec line is greyed out in the Array project. CLion seems to agree, _WINDLL isn't defined.

Array:
image

Sprite Game:
image

1 Like