Hey so I have this class function that I call from several places. Inside the function I'm calling rt_printf() for debugging/logging. If I then want to call the function from the classes' constructor the program will segfault when it starts. The class is a global object somewhere so its constructor is run when the program starts.

At what point is it safe to call rt_printf? It seems to me no earlier than setup()? Can I check somewhere if calling rt_printf is safe?

In dev there's a Bela_initRtBackend() https://github.com/BelaPlatform/Bela/blob/dev/core/RtWrappers.cpp#L323 which can safely be called more than once from any context. However, it may be expensive because it uses sts::call_once() so it shouldn't be called from a real-time context. After it's been called at least once you should be able to use rt_printf(). The gXenomaiInited flag could be used for a quick lookup (it's not in Bela.h so you need to devlare it as extern).

This said there's normally no point in using rt_printf() from a constructor: constructors tend to do non realtime safe stuff and are often accompanied by memory allocation (unless you use something like emplace_back, I guess?) And so in general they are not real-time safe and therefore there should be little use in using rt_printf over printf.