Hi everyone,

I’m working on a project where I deal with mach here and there, and strangely 
enough this C struct (from mach/processor_info.h)...

struct processor_cpu_load_info {             /* number of ticks while 
running... */
        unsigned int    cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */
}; 

is imported in Swift 3 (at least in Xcode8.1 beta) as…

public struct processor_cpu_load_info {

    public var cpu_ticks: (UInt32, UInt32, UInt32, UInt32) /* number of ticks 
while running... */ /* ... in the given mode */
    ...
}

I find it strange because the index of each UInt32 value depends on machine.h 
define(d) indexes for CPU_STATE_USER, CPU_STATE_SYSTEM etc… 

So the only way to access them in the tuple « format » is to hard code 
cpu_ticks.0 or cpu_ticks.1 etc… and thus we loose the defined named indexes 
from machine.h

Am I missing something? What do you guys think of this matter?

For me this tuple should have been at least imported with named fields or even 
better as [UInt32] array...

Best regards,
Thierry

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to