Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between _declspec and __declspec?

Tags:

c++

c

I sometimes see keywords starting with two underscores and other times just one. Is there any difference?

like image 780
devoured elysium Avatar asked Sep 09 '09 11:09

devoured elysium


1 Answers

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.
like image 101
Kirill V. Lyadvinsky Avatar answered Sep 20 '22 23:09

Kirill V. Lyadvinsky