Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reports the correct __cplusplus macro for MSVC IntelliSense Mode #6028

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface CompilerDefaults {
windowsSdkVersion: string;
intelliSenseMode: string;
rootfs: string;
cplusplusMacro: string;
}

export class CppProperties {
Expand All @@ -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[] = [];
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down