It's not just a question of style. This is likely break with a recent clang. Maybe gcc, too. The compiler has to check that the same named functions with C linkage are equivalent (i.e. receive the same arguments of the same type), and this is not the case with enums. This is one reason why Boost.WinAPI is so complicated.
My guess is that unless you are able to avoid enums altogether, you have no choice but to include windows.h. Maybe you could reduce the negative impact of that by providing a way to build that part of your library separately.
I missed the most obvious solution (I am using GetLastError because it's
shorter):
inline HANDLE_ kernel32_handle()
{
//it's a system dll, so I don't really need to clean up
static HANDLE_ h = get_module_handle("Kernel32.dll");
return h;
}
inline DWORD_ get_last_error()
{
typedef DWORD_ WINAPI (*GetLastError_t)();
static GetLastError_t p =
reinterpret_cast