【问题标题】:How can I call the C routine 'lseek'?如何调用 C 例程“lseek”?
【发布时间】:2020-05-28 14:16:57
【问题描述】:

如何调用 C 例程 lseekftellfseek? 我试过这个(macos 10.12.6):

import os
#flag -lsystem
#include <unistd.h>

seeker.v:150:11: error: unknown function: C.lseek 
  148 | // tell returns the current file position
  149 | fn (f os.File) tell() int {
  150 |     return C.lseek(f.fd, 0, C.SEEK_CUR)
  151 | }

【问题讨论】:

    标签: vlang


    【解决方案1】:

    您必须在使用 C 函数之前声明它们!

    fn C.lseek(fd, offset, whence int)
    

    这让 V 可以知道函数的参数,并进行类型检查。

    【讨论】:

      猜你喜欢
      • 2016-03-09
      • 1970-01-01
      • 2011-02-04
      • 2021-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-14
      相关资源
      最近更新 更多