Skip to content

Commit

Permalink
sys/time.h: include time.h
Browse files Browse the repository at this point in the history
Due to a Meson annoyance explained in a comment in sys/time.h, #include
<time.h> from sys/time.h.
  • Loading branch information
guijan committed Sep 6, 2023
1 parent c39bb58 commit a85f51d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ libobsd = library('obsd', src,
c_args: args,
install: not subproj,
include_directories: incdir,
# To prevent Meson from making the compiler confuse sys/time.h
# with time.h
implicit_include_directories: false,
dependencies: deps,
gnu_symbol_visibility: 'hidden',
override_options: link)
Expand Down
10 changes: 10 additions & 0 deletions src/time/sys/time.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
#if !defined(OBSD_H_TIME)
#define OBSD_H_TIME

/* Meson adds libobsd/src/time/sys to the include path and there's no way to
* remove it, which means someone might try to include time.h and end up being
* satisfied by sys/time.h. This will probably cause errors over missing types
* later (it does on HaikuOS, doesn't seem to on others), so make sure the right
* time.h is also included.
*/
#if defined(__HAIKU__)
#include <../posix/time.h>
#endif

#include <obsd_defs.h>
#pragma obsd sys_time.h #define OBSD_INC_NEXT sys/time.h
#pragma obsd sys_time.h #include <obsd_inc_next.h>
Expand Down

0 comments on commit a85f51d

Please sign in to comment.