Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nob.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
# ifdef __APPLE__
# include <mach-o/dyld.h>
# endif
# ifdef __FreeBSD__
# include <sys/sysctl.h>
# endif
# include <sys/types.h>
# include <sys/wait.h>
# include <sys/stat.h>
Expand Down Expand Up @@ -2284,6 +2287,12 @@ NOBDEF char *nob_temp_running_executable_path(void)
if (_NSGetExecutablePath(buf, &size) != 0) return "";
int length = strlen(buf);
return nob_temp_strndup(buf, length);
#elif defined(__FreeBSD__)
char buf[4096];
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
size_t length = sizeof(buf);
if (sysctl(mib, 4, buf, &length, NULL, 0) < 0) return "";
return nob_temp_strndup(buf, length);
#else
fprintf(stderr, "%s:%d: TODO: nob_temp_running_executable_path is not implemented for this platform\n", __FILE__, __LINE__);
return "";
Expand Down
3 changes: 3 additions & 0 deletions shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// TODO: "-std=c99", "-D_POSIX_C_SOURCE=200112L" didn't work for MacOS, don't know why, don't really care that much at the moment.
// Anybody who does feel free to investigate.
# define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-I.")
#elif defined(__FreeBSD__)
// "-D_POSIX_C_SOURCE=200112L" hides required symbols on FreeBSD
# define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-std=c99", "-ggdb", "-I.");
#else
# define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-std=c99", "-D_POSIX_C_SOURCE=200112L", "-ggdb", "-I.");
#endif
Expand Down