csapp ch10.1练习题
配置kotlin native

    linuxX64('csappCh10No1') {
        binaries {
            // Comment the next section to generate Kotlin/Native library (KLIB) instead of executable file:
            executable('csappCh10No1App') {
                // Change to specify fully qualified name of your application's entry point:
                entryPoint = 'csapp.main'
            }
        }
    }

kotlin代码

package csapp

import kotlinx.cinterop.*
import platform.posix.*

fun main() {
    val fd1 = open("foo.txt", O_RDONLY, 0)
    close(fd1)
    val fd2 = open("baz.txt", O_RDONLY, 0)
    println("fd2 = $fd2")
    exit(0)
}

结果
csapp ch10.1练习题
如果baz.txt存在,则返回一个小的整数,不存在则返回-1
csapp ch10.1练习题
书中的
csapp ch10.1练习题

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-12-04
  • 2021-06-02
猜你喜欢
  • 2021-06-06
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2021-10-14
  • 2021-07-28
相关资源
相似解决方案