Closed cdwfs closed 4 years ago
I got the same thing. If I include Windows.h before process.h, no problem, but if I don't, I get link errors.
eg.
error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl SetHandleInformation(void *,unsigned long,unsigned long)" (__imp_?SetHandleInformation@@YAHPEAXKK@Z) referenced in function subprocess_create
Which is weird, since process.h declares them as stdcall, not cdecl 🤔
And if I include Windows.h after, I get the same errors as you.
On it!
I'm getting linkage errors in C++ code that uses process.h; the predeclarations of various internal Windows API calls doesn't match what's eventually defined by windows.h, if both headers are included:
You can reproduce the problem by adding
#include <windows.h>
at the end of test.cpp.The error starts occurring in 5bdac3a7eade787; I think it has something to do with the narrowing of the
extern "C"
scope, which no longer includes the predeclarations. They're always defined asextern "C"
in windows.h; moving them inside anextern "C"
scope fixes the linkage error. Is there a reason they were moved outside that scope?