diff --git a/src/Generator.Tests/GeneratorTest.cs b/src/Generator.Tests/GeneratorTest.cs index 3415bb27..05e55920 100644 --- a/src/Generator.Tests/GeneratorTest.cs +++ b/src/Generator.Tests/GeneratorTest.cs @@ -49,6 +49,10 @@ namespace CppSharp.Utils Path.GetFullPath(Path.Combine(path, "../../deps/llvm/tools/clang/lib/Headers")) }; + if (IsMacOS) { + options.addArguments ("-stdlib=libc++"); + } + foreach (var header in headersPaths) options.addSystemIncludeDirs(header); @@ -105,6 +109,28 @@ namespace CppSharp.Utils throw new Exception("Could not find tests output directory"); } + + [DllImport ("libc")] + static extern int uname (IntPtr buf); + + public static bool IsMacOS { + get { + if (Environment.OSVersion.Platform != PlatformID.Unix) + return false; + + IntPtr buf = Marshal.AllocHGlobal (8192); + if (uname (buf) == 0) { + string os = Marshal.PtrToStringAnsi (buf); + switch (os) { + case "Darwin": + return true; + } + } + Marshal.FreeHGlobal (buf); + + return false; + } + } #endregion }