On the C/C++ side I don't need any knowledge about the returned data, I must
store the data, and send them via MPI to the other hosts and the data is pushed
into the lua_pcall function
Perhaps one of the many table serialization libraries [1] will help you solve the problem - convert anything to a string representation, send the string, and deserialize the data on the receiving side before passing the data to Lua.