dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 508 forks source link

Update LoadLibrary.c #8358

Closed drvoss closed 4 years ago

drvoss commented 4 years ago

Support Visual C++ compiler

jkotas commented 4 years ago

Could you please explain the problem that this change is fixing?

drvoss commented 4 years ago

@jkotas #define symLoad GetProcAddress The #define statement takes two strings. first identifier and second token-string. The #define line occurs compile error. ref : https://docs.microsoft.com/en-us/cpp/preprocessor/hash-define-directive-c-cpp?view=vs-2019

#include <unistd.h>
// ..
#ifndef F_OK
#define F_OK    0
#endif

Visual C++ has no unistd.h. It's for linux. So, if It can't find the F_OK definition, defined it.

HINSTANCE handle = LoadLibraryA(path); The default LoadLibrary defines LoadLibraryW. It takes Unicode as an argument. Path is ansi string. So I fix it LoadLibraryA. ref : https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryw