diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index 3f5bf87682..063de4329a 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -105,6 +105,7 @@ export interface CompilerDefaults { windowsSdkVersion: string; intelliSenseMode: string; rootfs: string; + cplusplusMacro: string; } export class CppProperties { @@ -126,6 +127,7 @@ export class CppProperties { private vcpkgIncludes: string[] = []; private vcpkgPathReady: boolean = false; private defaultIntelliSenseMode?: string; + private defaultCplusplusMacro?: string; private defaultCustomConfigurationVariables?: { [key: string]: string }; private readonly configurationGlobPattern: string = "c_cpp_properties.json"; private disposables: vscode.Disposable[] = []; @@ -187,6 +189,7 @@ export class CppProperties { this.defaultFrameworks = compilerDefaults.frameworks; this.defaultWindowsSdkVersion = compilerDefaults.windowsSdkVersion; this.defaultIntelliSenseMode = compilerDefaults.intelliSenseMode; + this.defaultCplusplusMacro = compilerDefaults.cplusplusMacro; this.rootfs = compilerDefaults.rootfs; // defaultPaths is only used when there isn't a c_cpp_properties.json, but we don't send the configuration changed event @@ -304,6 +307,8 @@ export class CppProperties { const abTestSettings: ABTestSettings = getABTestSettings(); const rootFolder: string = abTestSettings.UseRecursiveIncludes ? "${workspaceFolder}/**" : "${workspaceFolder}"; const defaultFolder: string = "${default}"; + let isDefaultIntelliSenseModeUsed: boolean = false; + let isDefaultdefaultCStandardUsed: boolean = false; // We don't add system includes to the includePath anymore. The language server has this information. if (isUnset(settings.defaultIncludePath)) { configuration.includePath = [rootFolder].concat(this.vcpkgIncludes); @@ -331,13 +336,18 @@ export class CppProperties { } if ((isUnset(settings.defaultCppStandard) || settings.defaultCppStandard === "") && this.defaultCppStandard) { configuration.cppStandard = this.defaultCppStandard; + isDefaultdefaultCStandardUsed = true; } if (isUnset(settings.defaultIntelliSenseMode) || settings.defaultIntelliSenseMode === "") { configuration.intelliSenseMode = this.defaultIntelliSenseMode; + isDefaultIntelliSenseModeUsed = true; } if (isUnset(settings.defaultCustomConfigurationVariables) || settings.defaultCustomConfigurationVariables === {}) { configuration.customConfigurationVariables = this.defaultCustomConfigurationVariables; } + if (isDefaultIntelliSenseModeUsed && isDefaultdefaultCStandardUsed && this.defaultCplusplusMacro) { + configuration.defines?.push(this.defaultCplusplusMacro); + } } private get ExtendedEnvironment(): Environment {