Skip to content

Commit

Permalink
Fix min/max macro usage to compile on Linux properly
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 committed Jun 22, 2018
1 parent 5cc040b commit 4546329
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/shell/shell_misc.cpp
Expand Up @@ -32,6 +32,14 @@
#include "../dos/cdrom.h"
#endif

#ifdef _MSC_VER
# define MIN(a,b) ((a) < (b) ? (a) : (b))
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#else
# define MIN(a,b) std::min(a,b)
# define MAX(a,b) std::max(a,b)
#endif

void DOS_Shell::ShowPrompt(void) {
char dir[DOS_PATHLENGTH];
dir[0] = 0; //DOS_GetCurrentDir doesn't always return something. (if drive is messed up)
Expand Down Expand Up @@ -217,7 +225,7 @@ void DOS_Shell::InputCommand(char * line) {
pos++;
}

const auto lgt = min(pos, end) - (line + str_index);
const auto lgt = MIN(pos, end) - (line + str_index);

for (auto i = 0; i < lgt; i++)
outc(static_cast<Bit8u>(line[str_index++]));
Expand All @@ -240,7 +248,7 @@ void DOS_Shell::InputCommand(char * line) {
pos++;
}

const auto lgt = abs(max(pos, beg) - (line + str_index));
const auto lgt = abs(MAX(pos, beg) - (line + str_index));

for (auto i = 0; i < lgt; i++) {
outc(8);
Expand Down

0 comments on commit 4546329

Please sign in to comment.