Monday, August 2, 2021

Reserved identifiers in C++.

 Reserved identifiers in C++: Leading underscore followed by capital letter.

Who are they reserved for? Microsoft?

That's a lot of people. Who is arbitrating them? Nobody?

Innocent user code, uses no reserved identifiers:

  #include <unordered_map>

  using namespace std;

  #import "C:\windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" no_namespace


Older compiler/library:

C:\s>cl /c i.cpp

Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64


c:\s\mscorlib.tlh(2511) : error C2872: '_Mutex' : ambiguous symbol

        could be 'c:\s\mscorlib.tlh(1321) : _Mutex'

        or       '...\9.0\VC\Include\yvals.h(723) : std::_Mutex'


Newer compiler/library:


c:\s>cl /c i.cpp

Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29915 for x64


i.cpp

C:\s\mscorlib.tlh(2686): error C2872: '_Hash': ambiguous symbol

C:\s\mscorlib.tlh(1661): note: could be '_Hash'

C:\...\MSVC\14.28.29910\include\xhash(340): note: or       'std::_Hash'


No comments:

Post a Comment