c++windowscallbackstd-functionwdk

std::function<__callback void (void)> vs std::function<void (void)>?


  1. std::function<__callback void (void)>
  2. std::function<void (void)> Please tell me about the difference between these two.

__callback appears to be the keyword provided by WDK. I think it's different from the function calling protocol I knew.

Do you also use it to use functions in normal user-level applications?

Is it a kind of user-friendly keyword that separately defines asynchronous functions?

What is the difference between 1 and 2 above, and when should I use number 1?


Solution

  • It's merely an annotation from Microsoft's SAL (source-code annotation language).

    From Advanced Annotations: "__callback - The function can be used as a function pointer". It is defined as:

    #define __callback __allowed(on_function)
    

    It doesn't do anything to the function signature, but is an allowed annotation on functions, so unless you are SAL-annotating your own code already, don't use __callback either.