diff --git a/Source/Tools/Flax.Build/Projects/VisualStudio/VCProjectGenerator.cs b/Source/Tools/Flax.Build/Projects/VisualStudio/VCProjectGenerator.cs
index a4d772e0d..53a6ab243 100644
--- a/Source/Tools/Flax.Build/Projects/VisualStudio/VCProjectGenerator.cs
+++ b/Source/Tools/Flax.Build/Projects/VisualStudio/VCProjectGenerator.cs
@@ -386,7 +386,9 @@ namespace Flax.Build.Projects.VisualStudio
// Override MSBuild .targets file with one that runs NMake commands (workaround for Rider not finding "Microsoft.Cpp.Default.props" file)
var cppTargetsFileContent = new StringBuilder();
+ cppTargetsFileContent.AppendLine("");
cppTargetsFileContent.AppendLine("");
+ cppTargetsFileContent.AppendLine(" ");
cppTargetsFileContent.AppendLine(" ");
cppTargetsFileContent.AppendLine(" ");
cppTargetsFileContent.AppendLine(" ");
@@ -408,10 +410,48 @@ namespace Flax.Build.Projects.VisualStudio
cppTargetsFileContent.AppendLine(string.Format(" {0}", debuggerWorkingDirectory));
cppTargetsFileContent.AppendLine(" ");
cppTargetsFileContent.AppendLine("");
+
+ // Workarounds for Rider language server to not show errors over well known symbols
+ Dictionary preprocessor = new Dictionary()
+ {
+ {"__attribute__(x)", ""},
+ {"__null", "0"},
+ {"__extension__", ""},
+ {"__asm__", "__asm"},
+ {"_SIZE_T", "1"},
+ };
+ // Undefine hardcoded MSVC definitions
+ HashSet undefine = new HashSet()
+ {
+ "_MSC_VER",
+ "_MSC_EXTENSIONS",
+ "_M_IX86",
+ "_WIN32",
+ };
+
+ // Expose all known preprocessor definitions known by the compiler to language server
+ var clangDefinitions = Utilities.ReadProcessOutput("clang++", "-dM -E -x c++ /dev/null");
+ foreach (var (def, val) in clangDefinitions.Split('\n').Select(x => (x.Split(' ')[1], x.Split(' ')[2])))
+ preprocessor.Add(def, val);
+
+ var workaroundsFileContent = new StringBuilder();
+ workaroundsFileContent.AppendLine($"");
+ workaroundsFileContent.AppendLine($"");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($" {string.Join(' ', undefine.Select(x => $"/U {x}"))} %(AdditionalOptions)");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($" /usr/include/c++/16/aarch64-redhat-linux/;$(NMakeIncludeSearchPath)");
+ workaroundsFileContent.AppendLine($" {string.Join(';', preprocessor.Select(x => $"{x.Key}={x.Value}"))};$(NMakePreprocessorDefinitions)");
+ workaroundsFileContent.AppendLine($" ");
+ workaroundsFileContent.AppendLine($"");
Utilities.WriteFileIfChanged(Path.Combine(projectDirectory, "Microsoft.Cpp.targets"), cppTargetsFileContent.ToString());
Utilities.WriteFileIfChanged(Path.Combine(projectDirectory, "Microsoft.Cpp.Default.props"), vcUserFileContent.ToString());
Utilities.WriteFileIfChanged(Path.Combine(projectDirectory, "Microsoft.Cpp.props"), vcUserFileContent.ToString());
+ Utilities.WriteFileIfChanged(Path.Combine(projectDirectory, "Rider.Workarounds.Cpp.props"), workaroundsFileContent.ToString());
}
// Save the files