users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calling c from gprolog


From: Pedro Salgueiro
Subject: calling c from gprolog
Date: Wed, 4 Jun 2003 03:17:48 -0700 (PDT)

Hi.
I'm trying to call c from gprolog and I have some
problems when I use the foreign type "-string" to
obtain the result of the c function.

This the file teste.c:

#include "gprolog.h"

Bool test(char *in, char *out){

  //out = (char *) malloc(1024*sizeof(char));
  //out = (char *) alloca(1024);

  sprintf(out, "teste");
  printf("IN:%s\n", in);
 
  return TRUE;          /* succeed */
};


And this is the file test.pl

:- foreign(test(+string,-string)).

when I compile both of them with:
gplc test.c test.pl
I get an executable file.
When I run this file and enter "test(xpto, X)."
gprolog 
just crahs, with the folowing error:

Fatal Error: Segmentation Violation

Anyone knows how to put this little exmaple working.

Thank's.
Pedro Salgueiro
./test

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]