The application is run remotely on target hardware. User can choose to enable visual debug output (using command line switches) in that case a ssh's X11 forwarding is used to view it.
The problem starts if user forgets to establish the connection before running the application like this: ssh -YC remote.host. The application will crash.
I would like to detect this situation beforehand and print proper message while starting the application. Is it possible to do it in C/C++? In the worst case I can execute some shell commands in the background.
You could use XOpenDisplay man page