Ferenc Wagner wrote:
For redirecting standard output to a file, I used
dup2 (fh, 1); printf ("Thing to write");
which didn't work in the cross-compiled program if it was linked with -mwindows. This issue is solved by using write() directly thus bypassing the stream level. Linking without -mwindows pops up a console, which is ugly and unnecessary, unless you use the -c command line option to select console mode. But once you link with -mwindows, you can't use stdio etc. on any level, not even if the program is run from a console. Which means that you can't have a program which both has a GUI and CLI, selected by some mechanism. The only way out is actively using the console API, at least to my present knowledge. I would be more than happy to stand corrected. It can't be such an exotic situation!
I couldn't find anything really clear on the subject. If you go the console API way, maybe this can help: http://c.conclase.net/conio/index.php (At the bottom there is a download thing.)
Jakobi