Coroutines in C

Started by
0 comments, last by dcosborn 15 years, 11 months ago
I've been reading a bit about Coroutines in C, and have even tried out a couple of options for coroutine systems, including this one, but none of the code I've tried works. With that last mention, I can get the source code to compile in GCC with a modified version posted on the forums here, but the code always crashes during run. I also tried the Portable Coroutines Library, but it seems it's not quite as portable as the title would make you believe, and it doesn't seem to support GCC on Win32. So have any of you guys(and gals) dealth with coroutines before as an option to full-featured scripting languages? If so, which coroutine libraries do you like? If not, do you think I'd just be better off using a language like AngelScript for my game(which is what I currently plan on using if coroutines don't work out)? Any replies would be much appreciated. Thank you for your time, -Wynter Woods
Advertisement
I was looking into the same thing recently. This series of articles might be of interest. The second page presents the idea of using Win32 Fibers to implement coroutines. Apparantly the idea has been successfully applied to Lua, allowing one to yield in the middle of a C function. You might look to Boost.Coroutine for implementation ideas, even if you're using C.

Notwithstanding the above, to actually get work done, I would suggest going with something like Lua, AngelScript, or another scripting language with built-in support for coroutines.

This topic is closed to new replies.

Advertisement