It does, after all, get defined in stddef.h AND c++config.h:
c++config.h:
namespace std
{
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
typedef decltype(nullptr) nullptr_t;
#endif
}
stddef.h:
typedef __SIZE_TYPE__ size_t;
So when a file does using namespace std
, the Eclipse CDT code analysis gets confused and says the symbol is ambiguous. I don't know how gcc works around this, but does anybody have any suggestions on what to do for the eclipse code analysis?
I got around this by just completely disabling that error in code analysis.
Project -> Properties -> C/C++ General -> Code Analysis
Uncheck 'Ambiguous problem'
It is mostly, but not entirely, true that valid C code is also valid C++ code. You've hit a case where that's not true. This question has a very good answer about the difference in this case: Repeated typedefs - invalid in C but valid in C++? It's also worth noting that C11 will fix this incompatibility.
The upshot, really, is that this behavior is somewhere between a deficiency and a defect in the CDT code analysis. CDT ought to know that the code is C++ and to allow the syntax, but it seems as if it thinks it's C and is disallowing it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With