Hi,

I'm trying to call a C++ function from a X10 class, using the following 
code.
It's working as expected (note the commented line in Hello.x10).

//============= Hello.x10 =======================================
public class Hello {

@Native("c++", "HelloWorld()")
extern public native def test():void;

public static def main(a: Rail[String]) : void
{
var H0:Hello = new Hello();
H0.test();

for(var j:int =0; j<Place.MAX_PLACES; j++)
async(here.next(j)) {
var H:Hello = new Hello();
Console.OUT.println("Hello from place " + here.id
+ " ( of "+Place.MAX_PLACES+" )");

// H.test(); <<=== commented line
}
}
}
//============= end of Hello.x10 ================================


//============= Hello_x10stub.c =================================
#include <iostream>

extern "C"
void HelloWorld()
{
std::cout << "Hello world from C" << std::endl;
}
//============= end of Hello_x10stub.c ===========================

To compile the code, I type :

x10c++ -commandlineonly -c Hello.x10
g++ -c -I/opt/x10/include -I/opt/x10 -I. -g -DTRANSPORT=sockets 
-DX10_USE_BDWGC -Wno-long-long -Wno-unused-parameter -U___DUMMY___ 
-msse2 -mfpmath=sse Hello.cc
g++ -g -pthread -msse2 -mfpmath=sse Hello.o -L/opt/x10/lib -lgc -lx10 
-lupcrts_sockets -ldl -lm -lpthread -Wl,-export-dynamic -lrt -o Hello.out


Now, if I uncomment H.test() in Hello, the first g++ command fails with 
the error :
Hello.inc : ‘HelloWorld’ was not declared in this scope

I think that the problem comes from the generated Hello.cc file.
This file starts with:

#include <Hello.h>
#include "Hello.inc"
#include <Hello_x10stub.c>

It would be better to generate:

#include <Hello.h>
#include <Hello_x10stub.c>
#include "Hello.inc"

Thanks for comments or suggestions

Marc




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to