Skip to content

Commit a32f83d

Browse files
authored
Set cppStandard from ros version (#1292)
Create a function that looks up ros version setting and then sets cppStandard variable accordingly ROS1:https://www.ros.org/reps/rep-0003.html ROS2:https://www.ros.org/reps/rep-2000.html Signed-off-by: Jonathan <jmblixt3@gmail.com>
1 parent 03591b4 commit a32f83d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/ros/build-env-utils.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function updateCppPropertiesInternal(): Promise<void> {
8484
cppProperties.configurations[0].intelliSenseMode = "gcc-" + process.arch
8585
cppProperties.configurations[0].compilerPath = "/usr/bin/gcc"
8686
cppProperties.configurations[0].cStandard = "gnu11"
87-
cppProperties.configurations[0].cppStandard = "c++14"
87+
cppProperties.configurations[0].cppStandard = getCppStandard()
8888

8989
// read the existing file
9090
try {
@@ -138,3 +138,29 @@ function updatePythonAutoCompletePathInternal() {
138138
function updatePythonAnalysisPathInternal() {
139139
vscode.workspace.getConfiguration().update(PYTHON_ANALYSIS_PATHS, extension.env.PYTHONPATH.split(path.delimiter));
140140
}
141+
142+
function getCppStandard() {
143+
switch (vscode.workspace.getConfiguration().get("ros.distro"))
144+
{
145+
case "kinetic":
146+
case "lunar":
147+
return "c++11"
148+
case "melodic":
149+
case "noetic":
150+
case "ardent":
151+
case "bouncy":
152+
case "crystal":
153+
case "dashing":
154+
case "eloquent":
155+
case "foxy":
156+
return "c++14"
157+
case "galactic":
158+
case "humble":
159+
case "iron":
160+
case "jazzy":
161+
case "rolling":
162+
return "c++17"
163+
default:
164+
return "c++17"
165+
}
166+
}

0 commit comments

Comments
 (0)