mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
compiler.h/file.c: include <windows.h> before Windows SDK headers
nasmlib/file.c included <stringapiset.h> directly (for MultiByteToWideChar()/CompareStringOrdinal()) without first including <windows.h>. Windows SDK headers like <stringapiset.h> are only guaranteed to work when pulled in through the normal <windows.h> pipeline, which sets up SDK-internal architecture macros (_X86_, _AMD64_, ...) derived from the compiler's own _M_IX86/_M_X64/etc. Including them directly skips that setup and can fail with a 'No Target Architecture' #error from <winnt.h> -- which is exactly what happened building with a real cl.exe/nmake in CI. Move the fix to include/compiler.h, since <windows.h> is needed broadly for Windows-specific functionality and other source files may hit the same problem in the future. Include it (with WIN32_LEAN_AND_MEAN) right after the _MBCS define, guarded by _WIN32, before anything else gets a chance to include a Windows SDK header on its own. file.c's direct <stringapiset.h> include is now redundant and removed; <wchar.h> is kept since it's still used for the wchar_t type. Confirmed fixed with a real MSVC (cl.exe/nmake) build in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e2f38a8aed
commit
d3cb1746d3
2 changed files with 18 additions and 1 deletions
|
|
@ -24,6 +24,22 @@
|
|||
/* On Microsoft platforms we support multibyte character sets in filenames */
|
||||
#define _MBCS 1
|
||||
|
||||
/*
|
||||
* On Windows, a number of source files need Windows API declarations
|
||||
* (e.g. MultiByteToWideChar(), CompareStringOrdinal()) that live in SDK
|
||||
* headers such as <stringapiset.h>. Those headers are only guaranteed
|
||||
* to work when included via the normal <windows.h> pipeline, which sets
|
||||
* up SDK-internal architecture macros (_X86_, _AMD64_, ...) that plain
|
||||
* compiler-provided macros (_M_IX86, _M_X64, ...) do not satisfy on
|
||||
* their own; including them directly can fail with "No Target
|
||||
* Architecture" errors from <winnt.h>. Pull in <windows.h> once, here,
|
||||
* before anything else gets a chance to jump the queue.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "autoconf/attribute.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@
|
|||
*/
|
||||
#ifdef _WIN32
|
||||
#include <wchar.h>
|
||||
#include <stringapiset.h>
|
||||
/* <windows.h> (which brings in MultiByteToWideChar()/CompareStringOrdinal()
|
||||
via <stringapiset.h>) is already included by "compiler.h". */
|
||||
|
||||
typedef wchar_t *os_filename;
|
||||
typedef wchar_t os_fopenflag;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue