fixes to allow the usage of clang on windows with the msvc abi and ms headers (#6442)

This commit is contained in:
Charlie Barto 2017-10-09 11:26:53 -04:00 • committed by Andreas Rumpf
commit d55e02ddf1
5 changed files with 20 additions and 18 deletions

View file

@ -83,16 +83,11 @@ when defined(posix) and not defined(JS):
elif defined(windows): elif defined(windows):
import winlean import winlean
when defined(vcc) or defined(bcc) or defined(icl):
# newest version of Visual C++ defines time_t to be of 64 bits # newest version of Visual C++ defines time_t to be of 64 bits
type TimeImpl {.importc: "time_t", header: "<time.h>".} = int64 type TimeImpl {.importc: "time_t", header: "<time.h>".} = int64
# visual c's c runtime exposes these under a different name # visual c's c runtime exposes these under a different name
var var
timezone {.importc: "_timezone", header: "<time.h>".}: int timezone {.importc: "_timezone", header: "<time.h>".}: int
else:
type TimeImpl {.importc: "time_t", header: "<time.h>".} = int
var
timezone {.importc, header: "<time.h>".}: int
type type
Time* = distinct TimeImpl Time* = distinct TimeImpl

View file

@ -2872,7 +2872,7 @@ when not defined(JS): #and not defined(nimscript):
importc: when defined(bcc): "setmode" else: "_setmode", importc: when defined(bcc): "setmode" else: "_setmode",
header: "<io.h>".} header: "<io.h>".}
var var
O_BINARY {.importc: "O_BINARY", nodecl.}: cint O_BINARY {.importc: "_O_BINARY", header:"<fcntl.h>".}: cint
# we use binary mode on Windows: # we use binary mode on Windows:
c_setmode(c_fileno(stdin), O_BINARY) c_setmode(c_fileno(stdin), O_BINARY)

View file

@ -103,7 +103,11 @@ proc c_sprintf(buf, frmt: cstring): cint {.
importc: "sprintf", header: "<stdio.h>", varargs, noSideEffect.} importc: "sprintf", header: "<stdio.h>", varargs, noSideEffect.}
# we use it only in a way that cannot lead to security issues # we use it only in a way that cannot lead to security issues
proc c_fileno(f: File): cint {. when defined(windows):
proc c_fileno(f: File): cint {.
importc: "_fileno", header: "<stdio.h>".}
else:
proc c_fileno(f: File): cint {.
importc: "fileno", header: "<fcntl.h>".} importc: "fileno", header: "<fcntl.h>".}
proc c_malloc(size: csize): pointer {. proc c_malloc(size: csize): pointer {.

View file

@ -15,8 +15,11 @@
{.push debugger:off .} # the user does not want to trace a part {.push debugger:off .} # the user does not want to trace a part
# of the standard library! # of the standard library!
when defined(windows):
proc c_fdopen(filehandle: cint, mode: cstring): File {. proc c_fdopen(filehandle: cint, mode: cstring): File {.
importc: "_fdopen", header: "<stdio.h>".}
else:
proc c_fdopen(filehandle: cint, mode: cstring): File {.
importc: "fdopen", header: "<stdio.h>".} importc: "fdopen", header: "<stdio.h>".}
proc c_fputs(c: cstring, f: File): cint {. proc c_fputs(c: cstring, f: File): cint {.
importc: "fputs", header: "<stdio.h>", tags: [WriteIOEffect].} importc: "fputs", header: "<stdio.h>", tags: [WriteIOEffect].}

View file

@ -14,8 +14,8 @@
import dynlib import dynlib
when defined(vcc):
{.passC: "-DWIN32_LEAN_AND_MEAN".} {.passC: "-DWIN32_LEAN_AND_MEAN".}
const const
useWinUnicode* = not defined(useWinAnsi) useWinUnicode* = not defined(useWinAnsi)