0

I want to have two main functions for GUI and Console mode.
Are there macros to detect what is set in Linker->System->SubSystem?

#ifdef ...
int main(int argc, char *argv[])
{
//...
}
#else
int main(int argc, char *argv[])
{
//...
}
#endif

_CONSOLE macro does not work for me.
And I don't use WinMain in my project. For GUI mode I also use main.

Ufx
  • 2,595
  • 12
  • 44
  • 83
  • So you want to create two different applications for the same purpose? I'd rather prefer having one single application that can be controlled via command line parameter (my personal favourite), environment variable, config file or whatever else appears appropriate for you... – Aconcagua Apr 21 '18 at 18:50
  • No. There is option Linker->System->SubSystem which allows to select run application as GUI or as Console. I want to test some code in console mode. That's why I want to have two main functions. – Ufx Apr 21 '18 at 18:52
  • Create two separate projects providing different main function and using some shared codebase. – user7860670 Apr 21 '18 at 18:55
  • You realize that console programs use main and Windows programs use WinMain right? – Retired Ninja Apr 21 '18 at 19:38
  • @RetiredNinja No. Both are main(). (Qt project). – Ufx Apr 21 '18 at 20:37

0 Answers0