Jakob Eriksson jakov@vmlinux.org writes:
Ferenc Wagner wrote:
this patch solves the immediate problem, but is not the full solution. How do you write a program which has both GUI and CUI? Is there any way to use standard IO in a program compiled with -mwindows but run from a console?
Hmm... what is the problem with GUI and command line interface. I don't think there should be any particalur problems, what happens?
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!