The following code can compile
#include <type_traits>
#include <iostream>
namespace win32 {
extern "C" {
#include <windows.h>
}
}
int main()
{
char buf[MAX_PATH]{};
win32::GetModuleFileNameA(nullptr, buf, std::extent_v<decltype(buf)> - 1);
std::cout << buf;
return 0;
}
But I'm not confident if it is safe to wrap windows header files in this way. Can I always do this on windows programming?