[Top][All Lists]

[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)

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

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

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

Fatal Error: Segmentation Violation

Anyone knows how to put this little exmaple working.

Pedro Salgueiro

Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).

reply via email to

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