Skip to content

Commit ca743db

Browse files
authored
Merge pull request #40 from tsoding/c99-posix-compliant
[v1.15.1] Make nob.h compilable in gcc/clang with -std=c99 on POSIX
2 parents f019011 + 757be46 commit ca743db

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.github/workflows/nob.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Clone GIT repo
2121
uses: actions/checkout@v4
2222
- name: Build nob
23-
run: ${{ matrix.cc }} -o nob nob.c
23+
run: ${{ matrix.cc }} -Wall -Wextra -std=c99 -D_POSIX_SOURCE -o nob nob.c
2424
- name: Run nob
2525
run: ./nob
2626
windows:

nob.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* nob - v1.15.0 - Public Domain - https://github.com/tsoding/nob.h
1+
/* nob - v1.15.1 - Public Domain - https://github.com/tsoding/nob.h
22
33
This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea.
44
@@ -1065,7 +1065,7 @@ bool nob_proc_wait(Nob_Proc proc)
10651065
}
10661066

10671067
if (WIFSIGNALED(wstatus)) {
1068-
nob_log(NOB_ERROR, "command process was terminated by %s", strsignal(WTERMSIG(wstatus)));
1068+
nob_log(NOB_ERROR, "command process was terminated by signal %s", WTERMSIG(wstatus));
10691069
return false;
10701070
}
10711071
}
@@ -1227,12 +1227,10 @@ Nob_File_Type nob_get_file_type(const char *path)
12271227
return -1;
12281228
}
12291229

1230-
switch (statbuf.st_mode & S_IFMT) {
1231-
case S_IFDIR: return NOB_FILE_DIRECTORY;
1232-
case S_IFREG: return NOB_FILE_REGULAR;
1233-
case S_IFLNK: return NOB_FILE_SYMLINK;
1234-
default: return NOB_FILE_OTHER;
1235-
}
1230+
if (S_ISREG(statbuf.st_mode)) return NOB_FILE_REGULAR;
1231+
if (S_ISDIR(statbuf.st_mode)) return NOB_FILE_DIRECTORY;
1232+
if (S_ISLNK(statbuf.st_mode)) return NOB_FILE_SYMLINK;
1233+
return NOB_FILE_OTHER;
12361234
#endif // _WIN32
12371235
}
12381236

@@ -1878,6 +1876,9 @@ int closedir(DIR *dirp)
18781876
/*
18791877
Revision history:
18801878
1879+
1.15.1 (2025-03-16) Make nob.h compilable in gcc/clang with -std=c99 on POSIX. This includes:
1880+
not using strsignal()
1881+
using S_IS* stat macros instead of S_IF* flags
18811882
1.15.0 (2025-03-03) Add nob_sv_chop_left()
18821883
1.14.1 (2025-03-02) Add NOB_EXPERIMENTAL_DELETE_OLD flag that enables deletion of nob.old in Go Rebuild Urself™ Technology
18831884
1.14.0 (2025-02-17) Add nob_da_last()

0 commit comments

Comments
 (0)