diff --git a/src/builtin_set_color.cpp b/src/builtin_set_color.cpp index a2fcd3ed1..f820a3539 100644 --- a/src/builtin_set_color.cpp +++ b/src/builtin_set_color.cpp @@ -60,7 +60,7 @@ static const struct woption long_options[] = {{L"background", required_argument, {L"print-colors", no_argument, nullptr, 'c'}, {nullptr, 0, nullptr, 0}}; -#if __APPLE__ +#ifdef __APPLE__ static char sitm_esc[] = "\x1B[3m"; static char ritm_esc[] = "\x1B[23m"; static char dim_esc[] = "\x1B[2m"; @@ -73,7 +73,7 @@ int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **argv) { // Hack in missing italics and dim capabilities omitted from MacOS xterm-256color terminfo // Helps Terminal.app/iTerm -#if __APPLE__ +#ifdef __APPLE__ const auto term_prog = parser.vars().get(L"TERM_PROGRAM"); if (!term_prog.missing_or_empty() && (term_prog->as_string() == L"Apple_Terminal" || term_prog->as_string() == L"iTerm.app")) { diff --git a/src/common.cpp b/src/common.cpp index 8271d4d94..d39012065 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -42,7 +42,7 @@ #ifdef __FreeBSD__ #include -#elif __APPLE__ +#elif defined(__APPLE__) #include #endif @@ -2219,13 +2219,13 @@ bool valid_func_name(const wcstring &str) { std::string get_executable_path(const char *argv0) { char buff[PATH_MAX]; -#if __APPLE__ +#ifdef __APPLE__ // On OS X use it's proprietary API to get the path to the executable. // This is basically grabbing exec_path after argc, argv, envp, ...: for us // https://opensource.apple.com/source/adv_cmds/adv_cmds-163/ps/print.c uint32_t buffSize = sizeof buff; if (_NSGetExecutablePath(buff, &buffSize) == 0) return std::string(buff); -#elif __FreeBSD__ +#elif defined(__FreeBSD__) // FreeBSD does not have /proc by default, but it can be mounted as procfs via the // Linux compatibility layer. Per sysctl(3), passing in a process ID of -1 returns // the value for the current process. diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 4be75f9ec..e8ccf229a 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -48,8 +48,8 @@ #include "wcstringutil.h" #include "wutil.h" -#if __APPLE__ -#define FISH_NOTIFYD_AVAILABLE 1 +#ifdef __APPLE__ +#define FISH_NOTIFYD_AVAILABLE #include #endif @@ -1186,7 +1186,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t { /// A notifyd-based notifier. Very straightforward. class universal_notifier_notifyd_t : public universal_notifier_t { -#if FISH_NOTIFYD_AVAILABLE +#ifdef FISH_NOTIFYD_AVAILABLE int notify_fd; int token; std::string name; @@ -1435,7 +1435,7 @@ class universal_notifier_named_pipe_t : public universal_notifier_t { }; universal_notifier_t::notifier_strategy_t universal_notifier_t::resolve_default_strategy() { -#if FISH_NOTIFYD_AVAILABLE +#ifdef FISH_NOTIFYD_AVAILABLE return strategy_notifyd; #elif defined(__CYGWIN__) return strategy_shmem_polling; diff --git a/src/expand.cpp b/src/expand.cpp index 4473b481f..9983ea856 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -16,7 +16,7 @@ #ifdef SunOS #include #endif -#if __APPLE__ +#ifdef __APPLE__ #include // Required to build with old SDK versions // proc.h needs to be included *after* time.h, this comment stops clang-format from reordering. #include diff --git a/src/fallback.cpp b/src/fallback.cpp index 92a4bb069..c44e55b37 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -113,7 +113,7 @@ int fish_mkstemp_cloexec(char *name_template) { return wcsncasecmp_fallback(a + 1, b + 1, count - 1); } -#if __APPLE__ +#ifdef __APPLE__ #if __DARWIN_C_LEVEL >= 200809L // Note parens avoid the macro expansion. wchar_t *wcsdup_use_weak(const wchar_t *a) { diff --git a/src/fallback.h b/src/fallback.h index 04f56158c..f9788755b 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -73,7 +73,7 @@ char *tparm_solaris_kludge(char *str, long p1 = 0, long p2 = 0, long p3 = 0, lon // these functions only exist on 10.7+. // // On other platforms, use what's detected at build time. -#if __APPLE__ +#ifdef __APPLE__ // Avoid warnings about unknown `clang::weak_import` attribute (e.g. GCC 8.2.0 on macOS 10.10) #if __DARWIN_C_LEVEL >= 200809L && __clang__ && __has_attribute(weak_import) // We have to explicitly redeclare these as weak, since we are forced to set the MIN_REQUIRED diff --git a/src/postfork.cpp b/src/postfork.cpp index 1fbf1641c..42101f208 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -9,7 +9,7 @@ #include #include -#if FISH_USE_POSIX_SPAWN +#ifdef FISH_USE_POSIX_SPAWN #include #endif #include diff --git a/src/postfork.h b/src/postfork.h index 91cc37aa8..2e7abc47b 100644 --- a/src/postfork.h +++ b/src/postfork.h @@ -40,7 +40,7 @@ pid_t execute_fork(); void safe_report_exec_error(int err, const char *actual_cmd, const char *const *argv, const char *const *envv); -#if FISH_USE_POSIX_SPAWN +#ifdef FISH_USE_POSIX_SPAWN /// Initializes and fills in a posix_spawnattr_t; on success, the caller should destroy it via /// posix_spawnattr_destroy. bool fork_actions_make_spawn_properties(posix_spawnattr_t *attr, diff --git a/src/topic_monitor.cpp b/src/topic_monitor.cpp index 779c5bffb..7a5fe7816 100644 --- a/src/topic_monitor.cpp +++ b/src/topic_monitor.cpp @@ -16,11 +16,11 @@ // block) and use use select() to poll it. #if defined(__has_feature) #if __has_feature(thread_sanitizer) -#define TOPIC_MONITOR_TSAN_WORKAROUND 1 +#define TOPIC_MONITOR_TSAN_WORKAROUND #endif #endif -#if __SANITIZE_THREAD__ -#define TOPIC_MONITOR_TSAN_WORKAROUND 1 +#ifdef __SANITIZE_THREAD__ +#define TOPIC_MONITOR_TSAN_WORKAROUND #endif /// Implementation of the principal monitor. This uses new (and leaks) to avoid registering a @@ -49,7 +49,7 @@ topic_monitor_t::topic_monitor_t() { // The read end must block to avoid spinning in await. DIE_ON_FAILURE(make_fd_nonblocking(pipes_.write.fd())); -#if TOPIC_MONITOR_TSAN_WORKAROUND +#ifdef TOPIC_MONITOR_TSAN_WORKAROUND DIE_ON_FAILURE(make_fd_nonblocking(pipes_.read.fd())); #endif } @@ -144,7 +144,7 @@ generation_list_t topic_monitor_t::await_gens(const generation_list_t &input_gen assert(gens == input_gens && "Generations should not have changed if we are the reader."); int fd = pipes_.read.fd(); -#if TOPIC_MONITOR_TSAN_WORKAROUND +#ifdef TOPIC_MONITOR_TSAN_WORKAROUND // Under tsan our notifying pipe is non-blocking, so we would busy-loop on the read() // call until data is available (that is, fish would use 100% cpu while waiting for // processes). The select prevents that.