boostorg / winapi

Windows API declarations without <windows.h>, for internal Boost use.
62 stars 58 forks source link

Add debugapi.hpp #39

Closed vinniefalco closed 7 years ago

vinniefalco commented 7 years ago

This is from the original <debugapi.h> windows header, I'm not sure how this translates into Boost.WinAPI speak:

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
vinniefalco commented 7 years ago

Please wait until I sign off before merging - feel free to review though :)

Lastique commented 7 years ago

All the APIs in Boost.WinAPI provide Boost-friendly declarations in the boost::detail::winapi namespace. The declarations in the global namespace are not supposed to be used outside Boost.WinAPI itself.

Lastique commented 7 years ago

Also, what is the reason to include debugapi.h?

vinniefalco commented 7 years ago

I just followed the example in this file, which looked the most similar: https://github.com/boostorg/winapi/blob/develop/include/boost/detail/winapi/dbghelp.hpp

vinniefalco commented 7 years ago

I've updated the branch based on your feedback

Lastique commented 7 years ago
  1. Please, don't provide boost::detail::winapi::IsDebuggerPresent if the API is not available.
  2. It would be better to do using ::OutputDebugStringA instead of the inline wrapper function. The wrapper functions are implemented only when using-declaration is not enough (mostly, when argument casts are required). Same for OutputDebugStringW.
  3. It would be nice to also provide boost::detail::winapi::output_debug_string inline function which calls ::OutputDebugStringA or ::OutputDebugStringW depending on the argument type.
vinniefalco commented 7 years ago

I'll make those changes. But, by not providing IsDebuggerPresent it just pushes the ugly version macro checking on to all callers. Are you sure that's what we want? Or maybe I'm missing something?

Lastique commented 7 years ago

That's the current convention with the other APIs. The user's code has to be aware of what Windows versions it targets and take steps, if necessary, to work around any missing optional (from the user's code perspective) APIs.

The point of Boost.WinAPI is not to re-implement Windows API where not present, but mostly avoiding inclusion of windows.h and workarounds for different Windows SDK bugs and quirks (read MinGW & co.) Boost.WinAPI also allows to configure the target Windows version.

Lastique commented 7 years ago

Thanks.