I would completely separate the business logic and graphical interface to stand-alone libraries - one for each. In the case of console application mode, I will refer to the only library that contains the logical part, and to both libraries. In doing so, you will not need to put # ifdef-s everywhere in your code and make reading difficult.
source
share