Hi Long,
strings in X10 are not C++ std::string instances, but objects that wrap
plain old C strings (const char*).
If you can change your C++ code to use char*, you could write:
class cpp {
@Native("c++","filetest(#1->c_str())")
static native def test(s:String):void;
}
The c_str() method on x10::lang::String just returns the contents of the
string.
Cheers,
Josh
On 01/02/13 04:10, Long Cheng wrote:
> Hello all,
>
> I try to pass a String parameter to C++ code as shown in the following
> code, but always meter the error "conversion from ‘x10::lang::String*’
> to non-scalar type ‘std::string’ requested". It's true that I define
> the function "void filetest(string s)" and use the "using namespace
> std;", for that I will meet the error that "type string can not be
> resolved" if I do not use "std" in the C++ code. I am not sure whether
> I did something wrong in the code?
>
> Thanks in advance!
>
> Long
>
> import x10.compiler.Native;
> import x10.compiler.NativeCPPInclude;
> import x10.compiler.NativeCPPCompilationUnit;
>
> @NativeCPPInclude("filetest.h")
> @NativeCPPCompilationUnit("filetest.cc")
>
> class cpp {
> @Native("c++","filetest(#1)")
> static native def test(s:String):void;
> }
>
> public class TEST {
> public static def main(args: Array[String]) {
> val C=new cpp();
> val path:String="/data/0.txt";
> C.test(path);
> }
> }
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_jan
> _______________________________________________
> X10-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users