FoundationEssentials: perform explicit conversion of mode_t#522
FoundationEssentials: perform explicit conversion of mode_t#522compnerd wants to merge 1 commit intoswiftlang:mainfrom
mode_t#522Conversation
|
@swift-ci please test |
| #endif | ||
|
|
||
| if fileType != S_IFREG { | ||
| if fileType != mode_t(S_IFREG) { |
There was a problem hiding this comment.
For my reference, could you elaborate a bit more on why these casts are all necessary? What type is S_IFREG on Windows? Does it use some other integer type, or does it use int? If so I think I'd expect that declaring a typealias mode_t = Int (or the appropriate integer type) would eliminate the need for these casts because S_IFREG would be considered the same type was fileType here. Or is there a detail I might be missing here?
There was a problem hiding this comment.
There is no mode_t on Windows, there is an alias that I have created which is int. However, the type system often sees the values as UInt16 which would then be incompatible with int. The explicit casting avoids the mismatched types on the various sides.
Windows uses `int` instead of a `mode_t` type. Create a shim alias in `_CShims` and use explicit type conversions to allow sharing of code paths across platforms. This helps reduce some of the build errors enabling further work to re-enable building FoundationEssentials on Windows.
|
@swift-ci test windows |
| #endif | ||
|
|
||
| #if defined(_WIN32) | ||
| typedef int mode_t; |
There was a problem hiding this comment.
What does mode_t mean on Windows? Why would we want Foundation to use UNIX/POSIX APIs on Windows?
There was a problem hiding this comment.
It means fewer code path divergences. Having a large number of #if os(...) conditionals hampers the ability to maintain the code path. Using the same terminology just is a convenience that is worth it. In general, Windows does have enough of the POSIX specification implemented to qualify as a POSIX compatible environment.
|
Let's hold off on this. I think that the recent |
|
Going to close this off. Instead of addressing the |
Windows uses
intinstead of amode_ttype. Create a shim alias in_CShimsand use explicit type conversions to allow sharing of code paths across platforms. This helps reduce some of the build errors enabling further work to re-enable building FoundationEssentials on Windows.