[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue

Charlie Monroe charlie at charliemonroe.net
Tue Jun 7 01:49:16 CDT 2016


This is a good point. This should, perhaps, be address using #if arch(x86_64), but you are right that many systems have some system typedefs defined otherwise even on the same architecture, which may be painful to deal with.

> Is there any need to consider the following common C sizeof() usage, which is currently illegal in Swift?
> 
> #if sizeof(MyType) != sizeof(Int)
> # error "Someone added too much data to MyType"
> #endif
> 
> It is not that I like fancy conditional compile, but having such compile time assertion is useful; at least in my day-time low-level C world. Most of the discussion seem to have been around sizeof() being more of a runtime function than a compiler directive; which would preclude being able to do compile time assertion to validate type size.
> 
> Dany
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list