一起编译多种语言 [英] Compiling multiple languages together
问题描述
可以一起编译多种语言,以获得最佳的不同语言。
Is it possible to compile multiple languages together in order to get the best of the different languages.
推荐答案
在编译它们之后,如果编译器和链接器都是兼容的,则将它们链接在一起(如果适当编程)。例如:
It's definitely possible to link them together (if suitably programmed) after compiling them separately, if the compilers and linkers are all compatible. For example:
g77 -c one.f
gcc -c two.c
gcc -o together one.o two.o
这会编译一个Fortran文件,然后是一个C文件,然后链接它们在一起的单个可执行文件在一起
(假设他们正确地互相调用;-)使用GCC工具套件。
this compiles a Fortran file, then a C file, then links them together in a single executable named together
(assuming they call each other properly;-) using the GCC suite of tools.
Microsoft的.NET是一种使用多种语言的流行方式 - C#,F#,IronPython,IronRuby等。 Visual Studio将处理编译成兼容代码和在程序集中加入在一起,但你也可以手动如果你想要的。
Microsoft's .NET is a popular way to use multiple languages together -- C#, F#, IronPython, IronRuby, and so on. Visual Studio will handle the compilations into compatible codes and the joining together in assemblies, but you can also do it "by hand" if you wish.
如果编译在一起你的意思是在同一个文件中有多种不同的语言,这也是可能的但很少见 - 例如一些C编译器有扩展名,让你在同一个文件中表达内联汇编语言。
If by "compiling together" you mean having multiple different languages within the same file, that's also possible but rarer -- for example some C compilers have extensions to let you express "inline" assembly language within the same file.
这篇关于一起编译多种语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!