Fix detecting Windows platform (#204)

This replaces _MSC_VER macro with _WIN32 because the
former one is for MSVC and Visual Studio only and is
not defined in mingw environment. Wherease, _WIN32
macro is the proper way to check Windows platform
irrespective of compiler toolchain.

See the following official link for more info
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
This commit is contained in:
Biswapriyo Nath 2023-05-13 09:36:53 +05:30 committed by GitHub
parent 05a52bab75
commit a277a590f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View file

@ -31,7 +31,7 @@
#include "libyasm-stdint.h"
#include "yasm-plugin.h"
#if defined(_MSC_VER)
#if defined(_WIN32)
#include <windows.h>
#elif defined(__GNUC__)
#include <dlfcn.h>
@ -43,7 +43,7 @@ static int num_loaded_plugins = 0;
static void *
load_dll(const char *name)
{
#if defined(_MSC_VER)
#if defined(_WIN32)
return LoadLibrary(name);
#elif defined(__GNUC__)
return dlopen(name, RTLD_NOW);
@ -62,7 +62,7 @@ load_plugin(const char *name)
/* Load library */
path = yasm_xmalloc(strlen(name)+10);
#if defined(_MSC_VER)
#if defined(_WIN32)
strcpy(path, name);
strcat(path, ".dll");
lib = load_dll(path);
@ -92,7 +92,7 @@ load_plugin(const char *name)
/* Get yasm_init_plugin() function and run it */
#if defined(_MSC_VER)
#if defined(_WIN32)
init_plugin =
(void (*)(void))GetProcAddress((HINSTANCE)lib, "yasm_init_plugin");
#elif defined(__GNUC__)
@ -115,7 +115,7 @@ unload_plugins(void)
return;
for (i = 0; i < num_loaded_plugins; i++) {
#if defined(_MSC_VER)
#if defined(_WIN32)
FreeLibrary((HINSTANCE)loaded_plugins[i]);
#elif defined(__GNUC__)
dlclose(loaded_plugins[i]);

View file

@ -26,7 +26,7 @@ typedef unsigned long uintptr_t;
#endif
#ifndef YASM_LIB_DECL
# if defined(BUILD_SHARED_LIBS) && defined(_MSC_VER)
# if defined(BUILD_SHARED_LIBS) && defined(_WIN32)
# ifdef YASM_LIB_SOURCE
# define YASM_LIB_DECL __declspec(dllexport)
# else

View file

@ -57,7 +57,7 @@ IF(regen_init_plugin_c)
"extern yasm_${_type}_module yasm_${_keyword}_LTX_${_type};\n")
ENDFOREACH(module)
IF(BUILD_SHARED_LIBS)
FILE(APPEND ${INIT_PLUGIN_C} "\n#ifdef _MSC_VER\n")
FILE(APPEND ${INIT_PLUGIN_C} "\n#ifdef _WIN32\n")
FILE(APPEND ${INIT_PLUGIN_C} "__declspec(dllexport)\n")
FILE(APPEND ${INIT_PLUGIN_C} "#endif\n")
ENDIF(BUILD_SHARED_LIBS)

View file

@ -3,7 +3,7 @@
extern yasm_arch_module yasm_dbg_LTX_objfmt;
#ifdef _MSC_VER
#ifdef _WIN32
__declspec(dllexport)
#endif
void

View file

@ -3,7 +3,7 @@
extern yasm_arch_module yasm_x86_LTX_arch;
#ifdef _MSC_VER
#ifdef _WIN32
__declspec(dllexport)
#endif
void