Skip to content

Commit e4f43df

Browse files
zfoggclaude
andcommitted
Fix gethostname compilation error in C2X mode
The gethostname function was failing to compile because the __unix__ macro is not defined when using -std=c2x. Updated the platform detection to be more robust by checking multiple Unix-like system macros. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f97cc69 commit e4f43df

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

test/bin_tests_debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdio.h>
33
#include <time.h>
44
#include <string.h>
5-
#ifdef __unix__
5+
#if defined(__unix__) || defined(__linux__) || defined(unix) || defined(__APPLE__)
66
#include <unistd.h>
77
#endif
88

@@ -65,7 +65,7 @@ void finalizeJunitXml(void) {
6565

6666
// Get hostname
6767
char hostname[256] = "unknown";
68-
#ifdef __unix__
68+
#if defined(__unix__) || defined(__linux__) || defined(unix) || defined(__APPLE__)
6969
if (gethostname(hostname, sizeof(hostname)) != 0) {
7070
strcpy(hostname, "unix-host");
7171
}

0 commit comments

Comments
 (0)