Skip to content

Commit

Permalink
Use macro OS_WINDOWS instead of __has_include
Browse files Browse the repository at this point in the history
Provides substitution of __has_include macro to OS_WINDOWS defined
in utils/os.h. The reason for this is to maintain a level of
consistency in RetDec source code base.
  • Loading branch information
Peter Kubov committed Jul 22, 2020
1 parent 5cd42f2 commit 5281e47
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/utils/io/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
#include <map>
#include <sstream>

#if __has_include(<windows.h>)
#include "retdec/utils/io/logger.h"
#include "retdec/utils/os.h"
#include "retdec/utils/time.h"

#if OS_WINDOWS
#include <io.h>
#include <windows.h>
#else
#include <unistd.h>
#endif

#include "retdec/utils/time.h"
#include "retdec/utils/io/logger.h"

namespace retdec {
namespace utils {
namespace io {
Expand All @@ -32,10 +33,12 @@ Logger::Logger(std::ostream& stream, bool verbose):
_out(stream),
_verbose(verbose)
{
#if __has_include(<windows.h>)
#if OS_WINDOWS
// On windows we need to try to set ENABLE_VIRTUAL_TERMINAL_PROCESSING.
// This will enable ANSI support in terminal. This is best effort
// implementation approach.
//
// Source: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
_terminalNotSupported = true;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE)
Expand Down Expand Up @@ -115,7 +118,7 @@ Logger& Logger::operator << (const Color& lc)

bool Logger::isRedirected(const std::ostream& stream) const
{
#if __has_include(<io.h>)
#if OS_WINDOWS
// On windows POSIX functions isatty and fileno
// generate Warning.
auto isConsole = _isatty;
Expand Down

0 comments on commit 5281e47

Please sign in to comment.