源代码缺少函数体,如何编译? [英] Source missing function body, how is it compiling?

查看:70
本文介绍了源代码缺少函数体,如何编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Go lang源代码中,我看到一个声明的函数,没有任何主体. https://github.com/golang/go/blob/master/src/math/log10.go#L9

In the Go lang source code, I see a function declared without any body. https://github.com/golang/go/blob/master/src/math/log10.go#L9

func Log10(x float64) float64

但是当我执行相同操作时,它给我一个错误:____缺少函数体

But when I do the same it gives me an error: missing function body for __

https://play.golang.org/p/Ncp-0-8vHB

这在Go源代码中如何工作?我的意思是数学软件包如何编译?此源文件仅用于文档目的吗?

How is this working in the Go source code? I mean how is the math package compiling? Is this source file just for documentation purposes?

Log10似乎是log10的公开/公开版本,但是没有"getter"约定或该语言中的类似内容,因此Log10的主体在哪里声明??

It seems like Log10 is a public/exposed version of log10, but there is no "getter" convention or anything like that in the language, so where is the body of Log10 declared???

推荐答案

它是在同一程序包的 *.s 文件中为各种体系结构在程序集中定义的.

It is defined in assembly for various architectures in the *.s files located in the same package.

每个规范:

函数声明可以省略主体.这样的声明为Go外部实现的功能(例如汇编例程)提供了签名.

A function declaration may omit the body. Such a declaration provides the signature for a function implemented outside Go, such as an assembly routine.

这篇关于源代码缺少函数体,如何编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆