Last active
August 29, 2015 14:12
-
-
Save ymurase/3f703809ab51e7876fb8 to your computer and use it in GitHub Desktop.
C++で定義された関数を呼ぶ方法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import x10.io.Console; | |
import x10.compiler.Native; | |
import x10.compiler.NativeCPPInclude; | |
import x10.compiler.NativeCPPCompilationUnit; | |
@NativeCPPInclude("MyCpp.hpp") | |
@NativeCPPCompilationUnit("MyCpp.cpp") | |
public class NativeCppTest { | |
@Native("c++", "my_double(#1)") | |
native static def double(n:Int): Int; | |
public static def main( args: Rail[String] ) { | |
{ | |
@Native("c++", "foo();") {} | |
} | |
val n = 30n; | |
val n2 = double(n); // 返り値もOK | |
Console.OUT.println("n2: " + n2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
外部のライブラリなどをリンクする場合、次のようにして -post オプション内でC++のコンパイル方法を指定する 。
x10c++ Test.x10 -post '# # -I /usr/local/blas # -L /usr/local/blas -lblas'