diff --git a/src/Core/Compilation.cs b/src/Core/Compilation.cs
index a5f715a3..4b3dcf28 100644
--- a/src/Core/Compilation.cs
+++ b/src/Core/Compilation.cs
@@ -12,7 +12,7 @@ namespace CppSharp
///
/// Target platform for code compilation.
///
- public TargetPlatform Platform;
+ public TargetPlatform? Platform;
///
/// Specifies the VS version.
diff --git a/src/Core/Platform.cs b/src/Core/Platform.cs
index e3bc75a2..093f19da 100644
--- a/src/Core/Platform.cs
+++ b/src/Core/Platform.cs
@@ -77,5 +77,22 @@ namespace CppSharp
return platform == PlatformID.Unix || platform == PlatformID.MacOSX;
}
}
+
+ public static TargetPlatform Host
+ {
+ get
+ {
+ if (IsWindows)
+ return TargetPlatform.Windows;
+
+ if (IsMacOS)
+ return TargetPlatform.MacOS;
+
+ if (IsLinux)
+ return TargetPlatform.Linux;
+
+ throw new NotImplementedException();
+ }
+ }
}
}
diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs
index c538e939..0fe95a5a 100644
--- a/src/Generator/Driver.cs
+++ b/src/Generator/Driver.cs
@@ -48,6 +48,9 @@ namespace CppSharp
void ValidateOptions()
{
+ if (!Options.Compilation.Platform.HasValue)
+ Options.Compilation.Platform = Platform.Host;
+
foreach (var module in Options.Modules)
{
if (string.IsNullOrWhiteSpace(module.LibraryName))