Want to run C code in Pharo using UFFI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Want to run C code in Pharo using UFFI

shawon58
Hello There
i am new to Pharo, so as i learn UFFI can handle c code, but i want to know
that, how to run below attached code using UFFI.

#include<stdlib.h>
#include<stdio.h>

int main( void ) {

  int result ;
  result=system("D:/DEV_FreeCAD/build/bin/box.step");
  printf("%d",result);
  return 0;
}


So if anyone have idea please share with me. It will be a great help to me.

Thanks for your kind help




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Reply | Threaded
Open this post in threaded view
|

Re: Want to run C code in Pharo using UFFI

eftomi
Hi, as far as I know UFFI can call DLLs, that means that your code should be compiled and linked into a DLL. So maybe the line to pursue is to look for a C interpreter (like in https://stackoverflow.com/questions/584714/is-there-an-interpreter-for-c) and call it via UFFI.

Best wishes,
Tomaz

Reply | Threaded
Open this post in threaded view
|

Re: Want to run C code in Pharo using UFFI

shawon58
hello
that means i need to create a ddl file and copy that file to pharo folder
than try to run the command directly using UFFI like
system("D:/DEV_FreeCAD/build/bin/box.step")

is it what u are trying to say @TOMAZ

Thanks by
Shawon



--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Reply | Threaded
Open this post in threaded view
|

Re: Want to run C code in Pharo using UFFI

eftomi
OK - maybe I misunderstood your original question - the purpose of UFFI is to call functions in DLLs outside Pharo, so yes, if you would like to call that kind of function, you have to build a DLL. The usage of UFFI is well described in its booklet: https://books.pharo.org/booklet-uffi/.

Best wishes
Tomaz


Reply | Threaded
Open this post in threaded view
|

Re: Want to run C code in Pharo using UFFI

Rob van Lopik
In reply to this post by shawon58
You may want to have a look at:

hth
rob van lopik

*******************************************