From 4d4d0aab87cfb55dd4a36cac2274f75dd77a9f7c Mon Sep 17 00:00:00 2001 From: Rene Hexel Date: Wed, 24 Apr 2024 22:33:10 +0000 Subject: [PATCH] Fix #7 by making g_ functions work under Linux. --- Sources/CGLib/glib_bridging.h | 5 +++++ Sources/GLib/GLib.swift | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Sources/CGLib/glib_bridging.h b/Sources/CGLib/glib_bridging.h index 107e733e..9c2dce22 100644 --- a/Sources/CGLib/glib_bridging.h +++ b/Sources/CGLib/glib_bridging.h @@ -1,3 +1,8 @@ +#ifdef __linux__ +#include +#include +extern int g_open (const char *, int, ...) __nonnull ((1)); +#endif #define __GLIB_H_INSIDE__ #include #include diff --git a/Sources/GLib/GLib.swift b/Sources/GLib/GLib.swift index d531732f..7bb82ef5 100644 --- a/Sources/GLib/GLib.swift +++ b/Sources/GLib/GLib.swift @@ -318,6 +318,7 @@ public func g_mkdir(_ path: UnsafePointer, _ mode: gint) -> CInt { return mkdir(path, mode_t(mode)) } +#if os(macOS) /// Open a file. /// /// This function is a wrapper around the `open()` system call, @@ -332,6 +333,7 @@ public func g_mkdir(_ path: UnsafePointer, _ mode: gint) -> CInt { public func g_open(_ path: UnsafePointer, _ flags: CInt, _ mode: gint = 0) -> CInt { return open(path, flags, mode_t(mode)) } +#endif /// Remove a filesystem object. ///