Skip to content

Build failure in linux #277

@csknns

Description

@csknns

Building in linux gives the following error

/home/x/Zip/Zip/Zip.swift:219:61: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
217 |                 let readBytes = unzReadCurrentFile(zip, &buffer, bufferSize)
218 |                 if readBytes > 0 {
219 |                     guard fwrite(buffer, Int(readBytes), 1, filePointer) == 1 else {
    |                                                             |- error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
    |                                                             |- note: coalesce using '??' to provide a default when the optional value contains 'nil'
    |                                                             `- note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
220 |                         throw ZipError.unzipFail
221 |                     }
/home/x/Zip/Zip/Zip.swift:219:61: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
217 |                 let readBytes = unzReadCurrentFile(zip, &buffer, bufferSize)
218 |                 if readBytes > 0 {
219 |                     guard fwrite(buffer, Int(readBytes), 1, filePointer) == 1 else {
    |                                                             |- error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
    |                                                             |- note: coalesce using '??' to provide a default when the optional value contains 'nil'
    |                                                             `- note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
220 |                         throw ZipError.unzipFail
221 |                     }
/home/x/Zip/Zip/Zip.swift:219:61: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
217 |                 let readBytes = unzReadCurrentFile(zip, &buffer, bufferSize)
218 |                 if readBytes > 0 {
219 |                     guard fwrite(buffer, Int(readBytes), 1, filePointer) == 1 else {
    |                                                             |- error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
    |                                                             |- note: coalesce using '??' to provide a default when the optional value contains 'nil'
    |                                                             `- note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
220 |                         throw ZipError.unzipFail
221 |                     }

You can see this in building a dependand library using github actions here.

It seems that Swift is unwilling to implicitly unwrap the optional UnsafeMutablePointer? when passing it to fwrite in linux enviroments.

Environment Informations
Zip: 2.1.2
Swift version: 6.0
Tested On: Ubuntu 24.04.2 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions