Vscode-cpptools: '"size_t" is ambiguous‘ when using WSL

Created on 8 Feb 2018  Â·  8Comments  Â·  Source: microsoft/vscode-cpptools

  • Operating System: Windows Pro 10.0.16299
  • VS Code version: 1.20.0, not a insider version
  • C/C++ extension version: 0.14.6

When I use "intelliSenseMode": "clang-x64" and using WSL(Ubuntu).
There are many '"size_t" is ambiguous' in problem panel.
My configure is just like the sample on https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/Windows%20Subsystem%20for%20Linux.md .

size_t is defined in both c++config.h and stddef.h. but the size_t in c++config.h is in a namespace(std). I think it should not report any problem if I use size_t(which I means ::size_t) as a type name.

vsc_cpp_issue_3
vsc_cpp_issue_4

.

Language Service bug duplicate

Most helpful comment

I added __SIZE_TYPE__=long unsigned int in c_cpp_properties.json defines list and solved this problem. In my case, I'm using std::size_t.

All 8 comments

I'll try to investigate this for March, unless @bobbrow can look at this earlier.

I added __SIZE_TYPE__=long unsigned int in c_cpp_properties.json defines list and solved this problem. In my case, I'm using std::size_t.

FYI, our March update should add __SIZE_TYPE__ automatically for compilers like clang that set it (it'll be set behind the scenes and won't appear in the c_cpp_properties, because the list of compiler defines is long), although the compilerPath might need to be changed if we guess the wrong compiler like /usr/bin/gcc which doesn't set that define.

1293 should cover this.

@bobbrow But in this case, this plugin use the right compiler and headers. There are two types, ::size_t and ::std::size_t, but it shows ambiguous when I use size_t. It should just use ::size_t .

I think #1293 is another problem which let users to specify the toolchains.

I can reproduce this with a very simple piece of code:

#include <bits/c++config.h>
#include <stddef.h>
using namespace std;
int main()
{
    size_t size;
}

If I don't define __SIZE_TYPE__ in c_cpp_properties.json, size_t is reported as ambiguous. If I define this, the error disappeared. So I do think this problem is related to #1293.

In your case, maybe you include a using namespace std by accident?

@huww98 __SIZE_TYPE__ is undefined maybe the problem. but If I include a using namespace std; by accident, it should also use std::size_t instead of showing ambiguous.

@owt5008137 I don't know if this is a duplicate or not, but if this still repros after our next update, we'll re-active it. We're trying to have an insider's build ready next week and the non-insider the following week.

UPDATE: WSL support for compilerPath did make it to 0.16.1, but we're planning for it with the April release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jyavenard picture jyavenard  Â·  3Comments

ecbrodie picture ecbrodie  Â·  3Comments

BDZNH picture BDZNH  Â·  3Comments

montery8 picture montery8  Â·  3Comments

arl picture arl  Â·  3Comments