I sometimes see keywords starting with two underscores and other times just one. Is there any difference?
+7
A:
I believe that _declspec
is older name of the same Microsoft specific keyword __declspec
. From a C++ Standard point of view, two underscores are more correct than a single underscore for an extension like this. That's according to 17.4.3.1.2/1:
Certain sets of names and function signatures are always reserved to the implementation:
- Each name that contains a double underscore (_ _) or begins with an underscore followed by an upper- case letter (2.11) is reserved to the implementation for any use.
- Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
Kirill V. Lyadvinsky
2009-09-09 12:09:03
Correct. That means you cannot declare a `_declspec()` function in the global namespace called , but you are allowed to declare a `_declspec()` method. For that reason Microsoft can't use `_declspec` as a keyword.
MSalters
2009-09-09 14:22:43