当从C调用go程序时,它是编译还是解释?

时间:2021-04-17 22:52:46

I made a C program. And I made a go file with go functions defined. In the C program, I called go functions. Is go called from C compiled or interpretted?

我做了一个C程序。我用go函数定义了一个go文件。在C程序中,我调用了go函数。是从C编译还是解释?

3 个解决方案

#1


3  

I made a C program. And I made a go file with go functions defined. In the C program, I called go functions

我做了一个C程序。我用go函数定义了一个go文件。在C程序中,我调用了go函数

You made a Go program which calls C functions (the other way around is not yet possible.) Then you're apparently calling Go functions from C again which is a bit weird and doesn't make much sense most of the time. See https://*.com/a/6147097/532430.

你做了一个调用C函数的Go程序(相反的方法还不可能。)然后你显然再次从C调用Go函数,这有点奇怪,并且在大多数时候没有多大意义。请参阅https://*.com/a/6147097/532430。

I'm going to assume you used gccgo to compile your program. Because if you used Go's gc then there wouldn't be any confusion about what language your program is written in.

我假设您使用gccgo编译程序。因为如果你使用Go的gc,那么你的程序编写的语言就不会有任何混淆。

Is go called from C compiled or interpretted?

是从C编译还是解释?

It's compiled. gccgo is a Go front-end for GCC. And GCC stands for GNU Compiler Collection.

它是编译的。 gccgo是GCC的Go前端。 GCC代表GNU Compiler Collection。

#2


3  

it is always compiled. C will never run function without compilation.

它总是被编译。如果没有编译,C将永远不会运行。

#3


-2  

In your program when you first call the go function,the compiler will generate the necessary codes for function call,space for function arguments,store details about function arguments type etc. If everything is correct as per the compiler standard,object file is created and further there are other processes like linking and all. So basically you cannot say it as " Is go called from C compiled or interpretted?",it's a series of processes which works together to make your program run.

在您的程序中,当您第一次调用go函数时,编译器将生成函数调用所需的代码,函数参数的空间,存储有关函数参数类型的详细信息等。如果根据编译器标准一切正确,则创建目标文件并还有其他过程,如链接和所有。所以基本上你不能说它是“从C编译或解释来调用吗?”,它是一系列协同工作以使程序运行的过程。

#1


3  

I made a C program. And I made a go file with go functions defined. In the C program, I called go functions

我做了一个C程序。我用go函数定义了一个go文件。在C程序中,我调用了go函数

You made a Go program which calls C functions (the other way around is not yet possible.) Then you're apparently calling Go functions from C again which is a bit weird and doesn't make much sense most of the time. See https://*.com/a/6147097/532430.

你做了一个调用C函数的Go程序(相反的方法还不可能。)然后你显然再次从C调用Go函数,这有点奇怪,并且在大多数时候没有多大意义。请参阅https://*.com/a/6147097/532430。

I'm going to assume you used gccgo to compile your program. Because if you used Go's gc then there wouldn't be any confusion about what language your program is written in.

我假设您使用gccgo编译程序。因为如果你使用Go的gc,那么你的程序编写的语言就不会有任何混淆。

Is go called from C compiled or interpretted?

是从C编译还是解释?

It's compiled. gccgo is a Go front-end for GCC. And GCC stands for GNU Compiler Collection.

它是编译的。 gccgo是GCC的Go前端。 GCC代表GNU Compiler Collection。

#2


3  

it is always compiled. C will never run function without compilation.

它总是被编译。如果没有编译,C将永远不会运行。

#3


-2  

In your program when you first call the go function,the compiler will generate the necessary codes for function call,space for function arguments,store details about function arguments type etc. If everything is correct as per the compiler standard,object file is created and further there are other processes like linking and all. So basically you cannot say it as " Is go called from C compiled or interpretted?",it's a series of processes which works together to make your program run.

在您的程序中,当您第一次调用go函数时,编译器将生成函数调用所需的代码,函数参数的空间,存储有关函数参数类型的详细信息等。如果根据编译器标准一切正确,则创建目标文件并还有其他过程,如链接和所有。所以基本上你不能说它是“从C编译或解释来调用吗?”,它是一系列协同工作以使程序运行的过程。