In unix environments the makecontext()/swapcontext()
family of functions is sometimes used to implement coroutines in C. However these functions directly manipulate the stack and the execution flow. Often when these low level functionalities are quite different when switching from C to C++.
So the question is, if there would be any problem with implementing coroutines using makecontext()
and swapcontext()
. Of course one obviously would have to take very good care, that an exception could never escape such a coroutine, since there would be no exception handler on the stack for this and the program would most likely segfault. But other than that is there any incompatibility between the way C++ handles things internally and makecontext()
and setcontext()
modify the execution path?