vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

configuration issue with c_cpp_properties.json : Win32/Linux/WSL

Open the-moog opened this issue 3 years ago • 1 comments

Discussed in https://github.com/microsoft/vscode-cpptools/discussions/9602

Originally posted by the-moog July 19, 2022 In the file c_cpp_properties.json you can have multiple entries in "configurations". Valid 'name' keys are anything, but "Win32" and "Linux" are used to indicate the platform and selected accordingly by default. (BTW: 32 bit windows pretty much no longer exists so why Win32??) But that's not my issue.

I was working in WSL (using WSL/Remote) and realised that it's pickng up settings from the wrong section. It's picking up path to GCC and Includes from the Win32 section instead of Linux. So the path format is wrong. "C:\...." etc. instead of /mnt/c/.. or /usr/... I can change it but the work is cross platform, so if I open the project in Windows, rather than WSL it would be wrong again.

Surely there should be a 'WSL' setting as the paths could easily be /mnt/c/... etc or at least use the Linux settings as the OS is Linux (WSL) not Windows.

the-moog avatar Jul 20 '22 08:07 the-moog

Hi @the-moog . I'm copying my response from the discussion, which I think should explain the issue.

You can name a config with any name you choose. Those are default names. If you define multiple configs in your c_cpp_properties.json, you can choose between them by clicking on the current config name in the bar at the bottom of the window when a C or C++ file is open.

image

... or by using the C/C++: Select a Configuration command. On a subsequent launch, the C/C++ extension will use the last configuration you had selected.

When I open a empty folder in VS Code in remote WSL, and run C/C++: Edit Configurations (JSON), I see that it creates a c_cpp_properties.json containing a configuration titled, Linux. It would appear to properly default to Linux via WSL. Perhaps you started with a Win32 configuration in your c_cpp_properties.json when you first opened it on WSL, which would cause it to remain set to Win32 even after adding a config titled Linux, until you select it. I believe you will get the behavior you expect if you select your Linux config as the current configuration. The extension should also default to using a config titled Linux (if it already exists) the first time you open a folder containing a pre-existing c_cpp_properties.json file containing a Linux config, on WSL.

There are various articles on the web explaining why the Win32 nomenclature is still used.

If you are seeing something that does not match what I explain above, please provide a repro scenario (steps, or a zip we can extract) so we might investigate further.

Colengms avatar Jul 20 '22 18:07 Colengms

This issue has been closed because it needs more information and has not had recent activity.

github-actions[bot] avatar Sep 19 '22 11:09 github-actions[bot]