简体   繁体   中英

C Struct Missing Properties in Swift Conversion

I'm using a C library in my Swift 3 application. One of the struct s defined in the library is defined thusly:

struct termRow {
    void *bitmaps[BITMAP_PTRS];
    int flags;
    uint64_t chars[];
};

In my Swift code, when I reference a property of this termRow type, I have access to the bitmaps and flags , but the chars array is nowhere to be found! In Xcode, the autocomplete tells the story -- no chars value:

在此处输入图片说明

My assumption here is that Swift is unable to translate uint64_t arrays? If that is the case, what can I do to make it work in my Swift code, without screwing things up for the rest of the library?

I assume from the image that your row variable is a local instance of struct termRow . Are you sure the chars array was initialized? An array at the end of a struct with no defined bounds is an array of indeterminate length; If it is not initialized (in the case of a local) or allocated (in the case of a pointer), then it technically doesn't exist. Maybe that's what Xcode is trying to tell you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM