[Top][All Lists]

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

Re: Linking C, C++ and Prolog

From: Vic Bancroft
Subject: Re: Linking C, C++ and Prolog
Date: Thu, 30 Jan 2003 14:20:55 -0500 (EST)

On Thu, 30 Jan 2003, [iso-8859-1] CARLOS EGEA wrote:

> I want to link c, C++ and Prolog, but i have a problem
> when i try to link with dynamic a library, that is
> implements in C++.

It would be helpful to see a code fragment, however, it may just be a matter of 
having the appropriate function signature.  For example, to avoid the c++
function name mangling, in your header file use a construct such as
  #ifdef __cplusplus
  extern "C" {

  int my_function( char * parameter );

  #ifdef __cplusplus

Then in your c++ implementation file, you would have,

  extern "C" int my_function( char * parameter ) {
        cout << parameter << endl;
        return 0;

This can then be called from prolog using the normal c call interface.


Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505 
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509 
Fellow, Artificial Intelligence Center              [v]706.542-0358 
Athens, Georgia  30602, U.S.A  

reply via email to

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