Hi,
In case anyone is interested in getting the Visual C++ support working again, I tried last July and was unable to get the support to where I was convinced it was correct. The changes that I tested are below – only 2 files changed.
These changes worked for a VC++ console application project, which is maybe all that is important for CDT support.
The problem that I had was with Win32 API applications. Code-assist was showing errors with Windows specific ‘types’ being undefined which should not have been undefined. I assumed that the problem was one of 2 things:
1. I wasn’t predefining the right set of environment variables
2. The CDT parser was failing on the Windows header files – which are quite complicated
I spent a lot of time trying to figure out what the problem was but never succeeded in solving it.
Regards,
Leo
org.eclipse.cdt\windows\org.eclipse.cdt.msw.build\src\org\eclipse\cdt\msw\build\WinDiscoveredPathInfo.java
@@ -1,7 +1,7 @@
/*******************************************************************************
- * Copyright (c) 2007 QNX Software Systems and others.
+ * Copyright (c) 2007, 2016 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
@@ -29,21 +29,31 @@ public class WinDiscoveredPathInfo implements IDiscoveredPathInfo {
// Include paths
paths = WinEnvironmentVariableSupplier.getIncludePath();
symbols.put("_M_IX86", "600");
symbols.put("_WIN32", "1");
- symbols.put("_MSC_VER", "1400");
+ symbols.put("_MSC_VER", "1900");
// Microsoft specific modifiers that can be ignored
symbols.put("__cdecl", "");
symbols.put("__fastcall", "");
symbols.put("__restrict", "");
symbols.put("__sptr", "");
symbols.put("__stdcall", "");
symbols.put("__unaligned", "");
symbols.put("__uptr", "");
symbols.put("__w64", "");
+ // Microsoft source-code annotation language (SAL) modifiers that can be ignored
+ //symbols.put("_In_", "");
+ //symbols.put("_Inout_", "");
+ //symbols.put("_Out_", "");
+ //symbols.put("_Outptr_", "");
+ //symbols.put("_In_opt_", "");
+ //symbols.put("_Inout_opt_", "");
+ //symbols.put("_Out_opt_", "");
+ //symbols.put("_Outptr_opt_", "");
+
// Redefine some things so that the CDT parser can handle them, until there is a VC specific parser
symbols.put("__forceinline", "__inline");
symbols.put("__int8", "char");
symbols.put("__int16", "short");
C:\Users\leo\workspace\org.eclipse.cdt\windows\org.eclipse.cdt.msw.build\src\org\eclipse\cdt\msw\build\WinEnvironmentVariableSupplier.java
@@ -6,10 +6,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.msw.build;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -30,10 +32,12 @@ import org.eclipse.core.runtime.Path;
public class WinEnvironmentVariableSupplier
implements IConfigurationEnvironmentVariableSupplier, IProjectEnvironmentVariableSupplier {
private static Map<String, IBuildEnvironmentVariable> envvars;
private static String sdkDir;
+ private static List<IPath> sdkIncPath = new ArrayList<IPath>();
+ private static List<IPath> sdkLibPath = new ArrayList<IPath>();
private static String vcDir;
private static class WindowsBuildEnvironmentVariable implements IBuildEnvironmentVariable {
private final String name;
@@ -94,47 +98,65 @@ public class WinEnvironmentVariableSupplier
if (value == null) {
value = reg.getLocalMachineValue("SOFTWARE\\Wow6432Node\\" + subkey, name);
}
return value;
}
-
- // Current support is for Windows SDK 8.0 with Visual C++ 11.0
- // or Windows SDK 7.1 with Visual C++ 10.0
- // or Windows SDK 7.0 with Visual C++ 9.0
- private static String getSDKDir() {
+
+ private static String initSDKVarsHelper(String version) {
WindowsRegistry reg = WindowsRegistry.getRegistry();
- String sdkDir = getSoftwareKey(reg, "Microsoft\\Microsoft SDKs\\Windows\\v8.0", "InstallationFolder");
- if (sdkDir != null)
- return sdkDir;
- sdkDir = getSoftwareKey(reg, "Microsoft\\Microsoft SDKs\\Windows\\v7.1", "InstallationFolder");
- if (sdkDir != null)
- return sdkDir;
- return getSoftwareKey(reg, "Microsoft SDKs\\Windows\\v7.0", "InstallationFolder");
+ String subkey = "Microsoft\\Microsoft SDKs\\Windows\\v" + version;
+ String sdkRoot = getSoftwareKey(reg, subkey, "InstallationFolder");
+ if (sdkRoot != null) {
+ // Verify that an include directory has been installed for this version
+ if (Files.exists(Paths.get(sdkRoot,"Include"))) {
+ // Initialize the SDK variables
+ sdkDir = sdkRoot;
+ if (version == "10.0") {
+ String fullVersion = getSoftwareKey(reg, subkey, "ProductVersion");
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\" + fullVersion + "\\ucrt")));
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\" + fullVersion + "\\um")));
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\" + fullVersion + "\\shared")));
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\" + fullVersion + "\\winrt")));
+ sdkLibPath.add(new Path(sdkDir.concat("Lib\\" + fullVersion + "\\ucrt\\x86")));
+ sdkLibPath.add(new Path(sdkDir.concat("Lib\\" + fullVersion + "\\um\\x86")));
+ } else if (version == "8.1") {
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\um")));
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\shared")));
+ sdkIncPath.add(new Path(sdkDir.concat("Include\\winrt")));
+ sdkLibPath.add(new Path(sdkDir.concat("Lib\\winv6.3\\um\\x86")));
+ }
+ return sdkDir;
+ }
+ }
+ return null;
}
- private static String getVCDir() {
+ // Current support is for the Windows SDK 8.1 through 10.0
+ private static void initSDKVars() {
+ String sdkRoot = initSDKVarsHelper("10.0");
+ if (sdkRoot != null)
+ return;
+ initSDKVarsHelper("8.1");
+ }
+
+ private static void initVCVars() {
WindowsRegistry reg = WindowsRegistry.getRegistry();
- String vcDir = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "11.0");
- if (vcDir != null)
- return vcDir;
- vcDir = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "10.0");
- if (vcDir != null)
- return vcDir;
- return getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "9.0");
+ String vcRoot = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "14.0");
+ if (vcRoot != null) {
+ vcDir = vcRoot;
+ } else {
+ vcDir = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "12.0");
+ }
}
public static IPath[] getIncludePath() {
// Include paths
List<IPath> includePaths = new ArrayList<IPath>();
- if (sdkDir != null) {
- includePaths.add(new Path(sdkDir.concat("Include")));
- includePaths.add(new Path(sdkDir.concat("Include\\gl")));
- }
-
if (vcDir != null) {
includePaths.add(new Path(vcDir.concat("Include")));
}
+ includePaths.addAll(sdkIncPath);
return includePaths.toArray(new IPath[0]);
}
private static void addvar(IBuildEnvironmentVariable var) {
envvars.put(var.getName(), var);
@@ -142,14 +164,12 @@ public class WinEnvironmentVariableSupplier
private static synchronized void initvars() {
if (envvars != null)
return;
envvars = new HashMap<String, IBuildEnvironmentVariable>();
-
- // The SDK Location
- sdkDir = getSDKDir();
- vcDir = getVCDir();
+ initSDKVars();
+ initVCVars();
if (sdkDir == null && vcDir == null) {
return;
}
@@ -164,26 +184,27 @@ public class WinEnvironmentVariableSupplier
// LIB
buff = new StringBuilder();
if (vcDir != null)
buff.append(vcDir).append("Lib;");
if (sdkDir != null) {
- buff.append(sdkDir).append("Lib;");
- buff.append(sdkDir).append("Lib\\win8\\um\\x86;");
+ for (IPath path : sdkLibPath) {
+ buff.append(path.toOSString()).append(';');
+ }
}
addvar(new WindowsBuildEnvironmentVariable("LIB", buff.toString(), IBuildEnvironmentVariable.ENVVAR_PREPEND));
// PATH
buff = new StringBuilder();
if (vcDir != null) {
buff.append(vcDir).append("..\\Common7\\IDE;");
buff.append(vcDir).append("..\\Common7\\Tools;");
- buff.append(vcDir).append("Bin;");
+ buff.append(vcDir).append("bin;");
buff.append(vcDir).append("vcpackages;");
}
if (sdkDir != null) {
- buff.append(sdkDir).append("Bin;");
+ buff.append(sdkDir).append("bin\\x86;");
}
addvar(new WindowsBuildEnvironmentVariable("PATH", buff.toString(), IBuildEnvironmentVariable.ENVVAR_PREPEND));
}
}
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Marc-André Laperle
Sent: Friday, March 24, 2017 3:42 PM
To: cdt-dev@xxxxxxxxxxx
Subject: Re: [cdt-dev] Visual C++ Support feature discontinued?