在GitHub Actions用cl.exe编译Windows版libuv时遇errno未声明错误
Looks like you're hitting a common header dependency issue with MSVC's CRT headers. The error stems from corecrt_memcpy_s.h referencing errno without the compiler having already included the header that defines it (<errno.h>). Here's how to fix it:
Solution 1: Force-include <errno.h> in your compile command
MSVC's cl tool has an /include flag that lets you force a header to be included before any source files. Add this to your command to ensure errno is declared early enough:
cl /c /MT -Iinclude -Iinclude\uv -Isrc /include:errno.h -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600 ${{ env.SOURCES }}
Solution 2: Add the required CRT macro definition
In some cases, MSVC hides certain standard definitions behind specific macros. Try adding _CRT_STDIO_INCLUDE_DEPRECATED_IOSTREAMS to your preprocessor definitions to ensure <errno.h> is properly pulled in by dependent headers:
cl /c /MT -Iinclude -Iinclude\uv -Isrc /include:errno.h -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600 -D_CRT_STDIO_INCLUDE_DEPRECATED_IOSTREAMS ${{ env.SOURCES }}
Why removing /MT didn't help
The /MT flag controls whether you link against the static CRT library, but errno is required regardless of static/dynamic linking. Removing it doesn't address the root issue of the missing header inclusion.
Just a quick sanity check: make sure your vcvars64.bat path is correct for your VS 2017 Enterprise installation (which it looks like it is) — this script sets up all the necessary environment variables for MSVC to find system headers correctly.
内容的提问来源于stack exchange,提问作者Bernardo Ramos

