0

I have found a code in my project like

if(::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) != 0)

OR

if(<Some Condition>)

{
    ::TranslateMessage(&msg);

    ::DispatchMessage(&msg);
}

What is the significance of ::?

And the code is related to JNI.

Is it because of Threaded programming(I don't know)?

IInspectable
  • 46,945
  • 8
  • 85
  • 181
Vivek S.
  • 29
  • 6

1 Answers1

2

That is the scope specifier.

There is more information here.

C++ names can be used only in certain regions of a program. This area is called the "scope" of the name. Scope determines the "lifetime" of a name that does not denote an object of static extent. Scope also determines the visibility of a name, when class constructors and destructors are called, and when variables local to the scope are initialized. (For more information, see Constructors and Destructors.) There are five kinds of scope:

  • Function scope
  • File scope
  • Class scope
  • Prototype scope

Read those articles for more information.


There are lots of tutorials about scope too.

A scope is a region of the program and broadly speaking there are three places, where variables can be declared −

  • Inside a function or a block which is called local variables,

  • In the definition of function parameters which is called formal parameters.

  • Outside of all functions which is called global variables.

I should point out that the same rules apply for functions. So if a function is defined in, for example, CDialog, and you want the global version and not the CDialog version, you use :: to access the global version.

Community
  • 1
  • 1
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164