Bill Allombert on Tue, 30 Aug 2005 16:21:13 +0200


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

Re: pari & c++


On Fri, Aug 26, 2005 at 06:12:49PM -0400, Sam Steingold wrote:
> when pari is built with C on cygwin
> but used with C++, I get the following linking error:
> 
> pari.o: In function `_Z13get_entry_docPc':
> pari.c:13: undefined reference to `dowin32ctrlc()'
> 
> here is line 13 in file pari.c:
> 
> char* get_entry_doc (char* s) { entree *e = is_entry(s); return e==NULL?NULL:e->help; }

Hello, I do not have a cygwin system to check, but the patch below
should fix this bug.

Thanks for your report!

I am afraid there are lots of similar bugs (missing extern "C"). If we
want to support libpari build with g++ we need to declare _every_
public symbols (functions or variables) as extern "C", else the
resulting library does not define the same symbols (due to mangling) so
has a different ABI from the standard one. We should probably wrap
definitions of global symbol with a macro. Alternatively we can
define _every_ public functions in either paripriv.h or paridecl.h.

Cheers,
Bill

Index: pari/src/headers/parisys.h
===================================================================
--- pari.orig/src/headers/parisys.h     2004-11-08 12:30:32.000000000 +0100
+++ pari/src/headers/parisys.h  2005-08-30 10:32:30.000000000 +0200
@@ -63,6 +63,8 @@
  * the SIGINT handler. On Win32, the handler is executed in another thread, and  * longjmp'ing into another thread's stack will utterly confuse the system.
  * Instead, we check whether win32ctrlc is set in new_chunk(). */
+BEGINEXTERN
   extern int win32ctrlc;
   void dowin32ctrlc();
+ENDEXTERN
 #endif