Fix Actions CI for MSVC

Fixes #616
This commit is contained in:
Rangi
2021-01-01 21:22:17 -05:00
committed by Eldred Habert
parent 77279984a5
commit 7e3fc1db03
6 changed files with 20 additions and 7 deletions

View File

@@ -31,7 +31,9 @@ option(TRACE_PARSER "Trace parser execution" OFF)
option(TRACE_LEXER "Trace lexer execution" OFF) option(TRACE_LEXER "Trace lexer execution" OFF)
if(MSVC) if(MSVC)
add_compile_options(/W1 /MP) # MSVC's standard library triggers warning C5105,
# "macro expansion producing 'defined' has undefined behavior"
add_compile_options(/std:c11 /W1 /MP /wd5105)
add_definitions(/D_CRT_SECURE_NO_WARNINGS) add_definitions(/D_CRT_SECURE_NO_WARNINGS)
else() else()
add_compile_options(-Wall -pedantic) add_compile_options(-Wall -pedantic)

View File

@@ -16,6 +16,7 @@
#include "asm/section.h" #include "asm/section.h"
#include "platform.h" // MIN_NB_ELMS
#include "types.h" #include "types.h"
#define HASHSIZE (1 << 16) #define HASHSIZE (1 << 16)
@@ -117,7 +118,7 @@ void sym_SetExportAll(bool set);
struct Symbol *sym_AddLocalLabel(char const *symName); struct Symbol *sym_AddLocalLabel(char const *symName);
struct Symbol *sym_AddLabel(char const *symName); struct Symbol *sym_AddLabel(char const *symName);
struct Symbol *sym_AddAnonLabel(void); struct Symbol *sym_AddAnonLabel(void);
void sym_WriteAnonLabelName(char name[static MAXSYMLEN + 1], uint32_t ofs, bool neg); void sym_WriteAnonLabelName(char buf[MIN_NB_ELMS(MAXSYMLEN + 1)], uint32_t ofs, bool neg);
void sym_Export(char const *symName); void sym_Export(char const *symName);
struct Symbol *sym_AddEqu(char const *symName, int32_t value); struct Symbol *sym_AddEqu(char const *symName, int32_t value);
struct Symbol *sym_AddSet(char const *symName, int32_t value); struct Symbol *sym_AddSet(char const *symName, int32_t value);

View File

@@ -39,4 +39,11 @@
# define SSIZE_MAX INT_MAX # define SSIZE_MAX INT_MAX
#endif #endif
/* MSVC doesn't support `[static N]` for array arguments from C99 */
#ifdef _MSC_VER
# define MIN_NB_ELMS(N)
#else
# define MIN_NB_ELMS(N) static (N)
#endif
#endif /* RGBDS_PLATFORM_H */ #endif /* RGBDS_PLATFORM_H */

View File

@@ -13,7 +13,7 @@ set(common_src
) )
find_package(PkgConfig) find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND) if(MSVC OR NOT PKG_CONFIG_FOUND)
# fallback to find_package # fallback to find_package
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
else() else()

View File

@@ -47,9 +47,12 @@
/* Neither MSVC nor MinGW provide `mmap` */ /* Neither MSVC nor MinGW provide `mmap` */
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
# include <windows.h> # define WIN32_LEAN_AND_MEAN // include less from windows.h
# include <fileapi.h> # include <windows.h> // target architecture
# include <winbase.h> # include <fileapi.h> // CreateFileA
# include <winbase.h> // CreateFileMappingA
# include <memoryapi.h> // MapViewOfFile
# include <handleapi.h> // CloseHandle
# define MAP_FAILED NULL # define MAP_FAILED NULL
# define mapFile(ptr, fd, path, size) do { \ # define mapFile(ptr, fd, path, size) do { \
(ptr) = MAP_FAILED; \ (ptr) = MAP_FAILED; \

View File

@@ -567,7 +567,7 @@ struct Symbol *sym_AddAnonLabel(void)
/* /*
* Write an anonymous label's name to a buffer * Write an anonymous label's name to a buffer
*/ */
void sym_WriteAnonLabelName(char buf[static MAXSYMLEN + 1], uint32_t ofs, bool neg) void sym_WriteAnonLabelName(char buf[MIN_NB_ELMS(MAXSYMLEN + 1)], uint32_t ofs, bool neg)
{ {
uint32_t id = 0; uint32_t id = 0;