klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 5ac4c893f705616f84bf2376a04f90e6b037645d
parent 962d81818dcaf760b5ed8017f75cda500570ba70
Author: James Adam Armstrong <gwenio@live.com>
Date:   Fri, 21 Mar 2014 18:25:04 -0400

Fixed compilation and linking issues for the MinGW tool chain.

- In kgffi.c a cast was needed to work with -Wall.

- In kgsystem.c the definition of the environ variable caused linking problems.

- In ksystem.win32.c, <io.h> is needed for _get_osfhandle().

Also notes on implementing ksystem_isatty() where updated to included how _isatty() functions on Windows.

Diffstat:
Msrc/kgffi.c | 2+-
Msrc/kgsystem.c | 11++++++++++-
Msrc/ksystem.win32.c | 4++++
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/kgffi.c b/src/kgffi.c @@ -368,7 +368,7 @@ static TValue ffi_win32_error_message(klisp_State *K, DWORD dwMessageId) NULL, dwMessageId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - &s, 0, NULL)) { + (LPTSTR)&s, 0, NULL)) { return kstring_new_b_imm(K, "Unknown error"); } else { TValue v = kstring_new_b_imm(K, s); diff --git a/src/kgsystem.c b/src/kgsystem.c @@ -220,7 +220,14 @@ void get_environment_variables(klisp_State *K) kapply_cc(K, xparams[0]); } -/* This should work in mingw as well as gcc */ +/* Redefining environ hides the definition + from <stdlib.h> on MinGW. + */ +#ifndef __MINGW32__ + +/* Note, when building for Windows if there is + a link error try commenting out the following + declaration. */ /* TODO test, if that doesn't work, try to find a way avoiding taking extra params in main */ /* I think it's defined in unistd, but it needs to have __USE_GNU @@ -233,6 +240,8 @@ __declspec(dllimport) #endif char **environ; +#endif + /* Helper for get-environment-variables */ TValue create_env_var_list(klisp_State *K) { diff --git a/src/ksystem.win32.c b/src/ksystem.win32.c @@ -6,6 +6,7 @@ #include <windows.h> #include <stdio.h> +#include <io.h> #include "kobject.h" #include "kstate.h" #include "kinteger.h" @@ -58,6 +59,9 @@ bool ksystem_isatty(klisp_State *K, TValue port) * - does not work in plain wine (works in wineconsole) * - probably won't work if Windows Console is replaced * a terminal emulator + * + * 3) _isatty() + * - calls GetFileType() internally (including MinGW version) * * TEMP: use GetConsoleMode() */