“//sys…”注释的含义是什么?

huangapple go评论97阅读模式
英文:

What do "//sys ..." comments mean?

问题

Microsoft的winio包中包含以//sys开头的注释。
例如:

//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe

我怀疑它们有特殊的含义。
这些注释是什么意思?
文档在哪里可以找到?

英文:

Microsoft's winio package contains comments starting with //sys.
For example:

//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe

I suspect they have special meaning.
What do these comments mean?
And where is the documentation?

答案1

得分: 1

mkwinsyscall 使用//sys注释来确定需要生成的代码:

mkwinsyscall 生成 Windows 系统调用的函数体。它解析命令行上指定的包含函数原型的所有文件(例如 syscall_windows.go),并将系统调用的函数体打印到标准输出。原型由以 "//sys" 开头的行标记,并且如果将 "//sys" 替换为 "func",则读取起来类似于函数声明,但是...

运行 go generate 将导致它被调用,原因是由于 这个注释(输出将被发送到 zsyscall_windows.go):

//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go ./*.go
英文:

mkwinsyscall uses the //sys comments to determine what code it needs to generate:

>mkwinsyscall generates windows system call bodies. It parses all files specified on command line containing function prototypes (like syscall_windows.go) and prints system call bodies to standard output.
>The prototypes are marked by lines beginning with "//sys" and read
like func declarations if //sys is replaced by func, but...

Running go generate will lead to it being called due to this comment (with output going to zsyscall_windows.go):

//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go ./*.go

huangapple
  • 本文由 发表于 2022年11月21日 13:12:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/74514494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定