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.


.
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.
@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.
Most helpful comment
I added
__SIZE_TYPE__=long unsigned intinc_cpp_properties.jsondefines list and solved this problem. In my case, I'm usingstd::size_t.