Skip to content

Commit

Permalink
meson: Pass -D_DARWIN_C_SOURCE on darwin
Browse files Browse the repository at this point in the history
This is probably a follow-up for 02ee2d0 ("fix macos build")
and unbreaks the build on Nixpkgs x86_64-darwin, probably due to
using even older SDKs?

https://github.com/NixOS/nixpkgs/runs/19486840382

```
> In file included from ../src/as-system-info.c:60:
> In file included from /nix/store/51c1k4sj0irwgyvkgbyhqi0ggilyh3j2-Libsystem-1238.60.2/include/sys/sysctl.h:83:
> /nix/store/51c1k4sj0irwgyvkgbyhqi0ggilyh3j2-Libsystem-1238.60.2/include/sys/ucred.h:91:2: error: unknown type name 'u_long'
>         u_long  cr_ref;                 /* reference count */
>         ^
> 1 error generated.
> ninja: build stopped: subcommand failed.
```

Instead of adding another typedef, apply the suggestions on pull
request 556 to pass `-D_DARWIN_C_SOURCE`, which seems to work fine
for us too.
  • Loading branch information
bobby285271 authored and ximion committed Dec 10, 2023
1 parent 25a7317 commit ccf292f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ if host_machine.system() != 'netbsd'
add_project_arguments('-D_POSIX_C_SOURCE=201710L', language: 'c')
endif

if host_machine.system() == 'darwin'
# See https://github.com/ximion/appstream/issues/551
add_project_arguments('-D_DARWIN_C_SOURCE', language: 'c')
endif

if cc.get_id() == 'clang'
# Clang doesn't understand autofree helpers on GMutexLocker and thinks
# these variables are irrelevant, so this warning when used with Clang
Expand Down
6 changes: 0 additions & 6 deletions src/as-system-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
#include <dirent.h>
#include <glib.h>

#if defined(__APPLE__)
typedef unsigned int u_int;
typedef unsigned char u_char;
typedef unsigned short u_short;
#endif

#if defined(__linux__)
#include <sys/sysinfo.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
Expand Down

0 comments on commit ccf292f

Please sign in to comment.