<div dir="ltr">The problem can be solved by modifying that code. Thanks you. I thought that code will affect only to the CLong type not Int.<div><br></div><div>But I meet another problem to fix it. I couldn't find the conditional method to distinct x86_64-*-windows-msvc with x86_64-*-windows-cygnus in Swift source.</div><div><br></div><div>"#if os(Windows)" can not distinct MSVC from Cygwin.</div><div><br></div><div>Should I add new condition 'env()' for the environment?</div><div><br></div><div>- Han Sangjin</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-26 14:39 GMT+09:00 John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Apr 25, 2016, at 7:54 PM, Sangjin Han via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br>
> Hi all,<br>
><br>
> I found a bug in my port for MSVC and Cygwin.<br>
><br>
> The C function swift_stdlib_readLine_stdin() is mapped to 'Int' type in Swift, but it generates i32 in LLVM if I specify the target as MSVC. If I give the target as Cygwin, it generates i64.<br>
><br>
> With the target options, the Cygwin ported swiftc.exe has the same output.<br>
><br>
> I know that the one of the differences between MSVC and Cygwin is the size of 'long' type. But I don't know even if it is related to this problem.<br>
><br>
> I don't know where to I start with.<br>
<br>
</span>The problem is probably the unconditional line<br>
public typealias CLong = Int<br>
in CTypes.swift. That is generally true for Unix platforms (LP32 / LP64) but not MSVC (LLP64).<br>
<br>
You will need to conditionalize that line.<br>
<br>
John.<br>
<span class=""><br>
><br>
> BEGIN OF tt.swift ---<br>
> import SwiftShims<br>
><br>
> var linePtr: UnsafeMutablePointer<CChar>? = nil<br>
> var readBytes = swift_stdlib_readLine_stdin(&linePtr)<br>
> print(readBytes)<br>
> END OF tt.swift -----<br>
><br>
> C:\temp>swiftc -emit-ir tt.swift -target x86_64-pc-windows-msvc | findstr stdlib<br>
> %4 = call i32 @swift_stdlib_readLine_stdin(i8** bitcast (%Sq* @_Tv2tt7linePtrGSqGSpVs4Int8__ to i8**))<br>
> declare i32 @swift_stdlib_readLine_stdin(i8**) #0<br>
><br>
> C:\temp>swiftc -emit-ir tt.swift -target x86_64-unknown-windows-cygnus | findstr stdlib<br>
> %4 = call i64 @swift_stdlib_readLine_stdin(i8** bitcast (%Sq* @_Tv2tt7linePtrGSqGSpVs4Int8__ to i8**))<br>
> declare i64 @swift_stdlib_readLine_stdin(i8**) #0<br>
><br>
><br>
> - Han Sangjin<br>
><br>
</span>> _______________________________________________<br>
> swift-dev mailing list<br>
> <a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
<br>
</blockquote></div><br></div>