diff --git a/lib/src/portable/endian.h b/lib/src/portable/endian.h index 6aa4438d..51defc5e 100644 --- a/lib/src/portable/endian.h +++ b/lib/src/portable/endian.h @@ -18,16 +18,20 @@ #if defined(HAVE_ENDIAN_H) || \ defined(__linux__) || \ defined(__GNU__) || \ + defined(__NetBSD__) || \ defined(__OpenBSD__) || \ defined(__CYGWIN__) || \ defined(__MSYS__) || \ defined(__EMSCRIPTEN__) +#if defined(__NetBSD__) +#define _NETBSD_SOURCE 1 +#endif + # include #elif defined(HAVE_SYS_ENDIAN_H) || \ defined(__FreeBSD__) || \ - defined(__NetBSD__) || \ defined(__DragonFly__) # include diff --git a/lib/src/query.c b/lib/src/query.c index 05eddef5..eb4e906c 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -1,3 +1,12 @@ +/* + * On NetBSD, defining standard requirements like this removes symbols + * from the namespace; however, we need non-standard symbols for + * endian.h. + */ +#if defined(__NetBSD__) && defined(_POSIX_C_SOURCE) +#undef _POSIX_C_SOURCE +#endif + #include "tree_sitter/api.h" #include "./alloc.h" #include "./array.h"