Skip to content

Commit 7036709

Browse files
committed
feat: allow compiling on macOS and any other POSIX-compliant OS
1 parent dfa572b commit 7036709

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

src/char.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifdef _WIN32
22
#include <windows.h>
33
#include <conio.h>
4-
#elif defined(__linux__)
4+
#else
55
#include <unistd.h>
66
#include <termios.h>
77
#endif
@@ -12,7 +12,7 @@ namespace char_utils {
1212
inline char get_char() {
1313
#ifdef _WIN32
1414
return _getch();
15-
#elif defined(__linux__)
15+
#else
1616
struct termios oldt, newt;
1717
char ch;
1818
tcgetattr(STDIN_FILENO, &oldt);
@@ -22,8 +22,6 @@ namespace char_utils {
2222
ch = getchar();
2323
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
2424
return ch;
25-
#else
26-
return '\0';
2725
#endif
2826
}
2927
}

src/main.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifdef _WIN32
1313
#include <windows.h>
1414
#include <conio.h>
15-
#elif defined(__linux__)
15+
#else
1616
#include <unistd.h>
1717
#include <termios.h>
1818
#endif
@@ -239,15 +239,12 @@ void checkCurlIsInstalled() {
239239
std::cout << "Curl not installed. Install it by running: winget install cURL.cURL\n";
240240
exit(1);
241241
}
242-
#elif defined(__linux__)
242+
#else
243243
int curl = system("curl --version >/dev/null 2>&1");
244244
if (curl != 0) {
245245
std::cout << "Curl not installed. As a Linux user, you are expected to know how to install it.\n";
246246
exit(1);
247247
}
248-
#else
249-
std::cout << "Unsupported OS. Please make sure you have modified the source code before compiling for another OS.";
250-
exit(10);
251248
#endif
252249
}
253250

0 commit comments

Comments
 (0)