changeset 1650:34abfb24e891

[xemacs-hg @ 2003-08-28 15:44:04 by james] Fix the C++ build, with many module-specific fixes.
author james
date Thu, 28 Aug 2003 15:44:30 +0000
parents 9afdad50eaf7
children d3af5b868526
files lwlib/ChangeLog lwlib/lwlib-internal.h modules/ChangeLog modules/common/Makefile.common src/ChangeLog src/emodules.h src/lisp.h src/lrecord.h src/mule-canna.c src/mule-wnnfns.c src/opaque.h src/process.h src/symeval.h src/text.h
diffstat 14 files changed, 155 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/ChangeLog	Wed Aug 27 21:52:30 2003 +0000
+++ b/lwlib/ChangeLog	Thu Aug 28 15:44:30 2003 +0000
@@ -1,3 +1,7 @@
+2003-08-28  Jerry James  <james@xemacs.org>
+
+	* lwlib-internal.h: Wrap assert_failed with EXTERN_C for modules.
+
 2003-06-01  Steve Youngs  <youngs@xemacs.org>
 
 	* XEmacs 21.5.14 "cassava" is released.
--- a/lwlib/lwlib-internal.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/lwlib/lwlib-internal.h	Thu Aug 28 15:44:30 2003 +0000
@@ -6,7 +6,7 @@
 #ifdef USE_ASSERTIONS
 /* Highly dubious kludge */
 /*   (thanks, Jamie, I feel better now -- ben) */
-void assert_failed (const char *, int, const char *);
+EXTERN_C void assert_failed (const char *, int, const char *);
 # define abort() (assert_failed (__FILE__, __LINE__, "abort()"))
 # define assert(x) ((x) ? 1 : (assert_failed (__FILE__, __LINE__, #x), 0))
 #else
--- a/modules/ChangeLog	Wed Aug 27 21:52:30 2003 +0000
+++ b/modules/ChangeLog	Thu Aug 28 15:44:30 2003 +0000
@@ -1,3 +1,9 @@
+2003-08-28  Jerry James  <james@xemacs.org>
+
+	* common/Makefile.common (LIBSTDCPP): New.
+	* common/Makefile.common (.c.o): Use it to avoid undefined symbol
+	errors when compiling  modules with g++.
+
 2003-08-18  Jerry James  <james@xemacs.org>
 
 	* postgresql/postgresql.c: Include emodules.h when building a module.
--- a/modules/common/Makefile.common	Wed Aug 27 21:52:30 2003 +0000
+++ b/modules/common/Makefile.common	Thu Aug 28 15:44:30 2003 +0000
@@ -57,6 +57,7 @@
 INSTALLPATH=@INSTALLPATH@
 INSTALL_PROGRAM=@MOD_INSTALL_PROGRAM@
 OBJECT_TO_BUILD=@OBJECT_TO_BUILD@
+LIBSTDCPP=@LIBSTDCPP@
 #ifdef HAVE_MS_WINDOWS
 IMPORT_LIB=../../src/xemacs-import.a
 #endif
@@ -69,7 +70,7 @@
 
 $(MODNAME).ell: $(OBJS) $(MODNAME)_i.o $(IMPORT_LIB)
 	$(MODCC) --mode=link --mode=verbose --mod-output=$@ \
-	$(OBJS) $(MODNAME)_i.o $(IMPORT_LIB) $(LDFLAGS)
+	$(OBJS) $(MODNAME)_i.o $(IMPORT_LIB) $(LDFLAGS) $(LIBSTDCPP)
 
 $(MODNAME)_i.c: $(SRCS)
 	ELLMAKEDOC=$(MAKE_DOCFILE) $(MODCC) --mode=init --mod-output=$@ \
--- a/src/ChangeLog	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/ChangeLog	Thu Aug 28 15:44:30 2003 +0000
@@ -1,3 +1,27 @@
+2003-08-28  Jerry James  <james@xemacs.org>
+
+	* emodules.h: Add extern "C" declarations for C++ module builds.
+	* lisp.h: Ditto.
+	* lrecord.h: Ditto.
+	* opaque.h: Ditto.
+	* process.h: Ditto.
+	* symeval.h: Ditto.
+	* text.h: Ditto.
+	* mule-canna.c: Make key_buffer char instead of unsigned char.
+	* mule-canna.c (storeResults): 1st arg is char *, not unsigned
+	char *.
+	* mule-canna.c (Fcanna_initialize): Add casts for C++ builds.
+	* mule-canna.c (Fcanna_finalize): Ditto.
+	* mule-canna.c (Fcanna_touroku_string): Ditto.
+	* mule-canna.c (Fcanna_store_yomi): Ditto.
+	* mule-canna.c (Fcanna_parse): Ditto.
+	* mule-canna.c (Fcanna_query_mode): Ditto, and change buf to
+	unsigned char[] to reduce number of casts.
+	* mule-canna.c (Fcanna_henkan_begin): Ditto.
+	* mule-canna.c (Fcanna_henkan_next): Ditto.
+	* mule-canna.c (mule_make_string): Ditto.
+	* mule-wnnfns.c (Fwnn_open): Ditto.
+
 2003-08-26  Nickolay Pakoulin  <npak@ispras.ru>
 
 	* database.c (berkdb_get):
--- a/src/emodules.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/emodules.h	Thu Aug 28 15:44:30 2003 +0000
@@ -73,10 +73,10 @@
  * into the right place. These functions will be called by the module
  * init code, generated by ellcc during initialization mode.
  */
-extern MODULE_API void emodules_doc_subr (const char *objname,
-					  const char *docstr);
-extern MODULE_API void emodules_doc_sym (const char *objname,
-					 const char *docstr);
+EXTERN_C MODULE_API void emodules_doc_subr (const char *objname,
+					    const char *docstr);
+EXTERN_C MODULE_API void emodules_doc_sym (const char *objname,
+					   const char *docstr);
 
 #define CDOCSUBR(Fname, DOC) emodules_doc_subr (Fname, DOC)
 #define CDOCSYM(Sname, DOC)  emodules_doc_sym  (Sname, DOC)
--- a/src/lisp.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/lisp.h	Thu Aug 28 15:44:30 2003 +0000
@@ -1005,6 +1005,10 @@
    data of TYPE. */
 #define ALIGN_PTR(ptr, type) ((void *) ALIGN_FOR_TYPE ((size_t) (ptr), type))
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* ------------------------ assertions ------------------- */
 
 /* We define assert iff USE_ASSERTIONS or DEBUG_XEMACS is defined.
@@ -1672,12 +1676,20 @@
 
 /* OK, you can open them again */
 
+#ifdef __cplusplus
+}
+#endif
+
 /************************************************************************/
 /**		     Definitions of basic Lisp objects		       **/
 /************************************************************************/
 
 #include "lrecord.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*------------------------------ unbound -------------------------------*/
 
 /* Qunbound is a special Lisp_Object (actually of type
@@ -2827,6 +2839,9 @@
 int finish_marking_weak_lists (void);
 void prune_weak_lists (void);
 
+#ifdef __cplusplus
+}
+#endif
 
 /************************************************************************/
 /*      Definitions related to the format of text and of characters     */
@@ -2954,6 +2969,10 @@
 
 #include "symeval.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* `specpdl' is the special binding/unwind-protect stack.
 
    Knuth says (see the Jargon File):
@@ -3138,6 +3157,10 @@
 
 extern MODULE_API struct gcpro *gcprolist;
 
+#ifdef __cplusplus
+}
+#endif
+
 /* #### Catching insufficient gcpro:
 
    The C++ code below catches GCPRO without UNGCPRO or vice-versa.
@@ -3204,6 +3227,10 @@
    and so some "This function can GC" comments may be inaccurate.
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef DEBUG_GCPRO
 
 MODULE_API void debug_gcpro1 (char *, int, struct gcpro *, Lisp_Object *);
@@ -3499,6 +3526,10 @@
 int begin_gc_forbidden (void);
 void end_gc_forbidden (int count);
 
+#ifdef __cplusplus
+}
+#endif
+
 
 /************************************************************************/
 /*		              Misc definitions        	                */
@@ -3523,6 +3554,10 @@
 /* Prototypes for all init/syms_of/vars_of initialization functions. */
 #include "symsinit.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Defined in abbrev.c */
 MODULE_API EXFUN (Fexpand_abbrev, 0);
 
@@ -5263,4 +5298,8 @@
 extern Lisp_Object Vthis_command_keys, Vunread_command_event;
 extern Lisp_Object Vx_initial_argv_list;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* INCLUDED_lisp_h_ */
--- a/src/lrecord.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/lrecord.h	Thu Aug 28 15:44:30 2003 +0000
@@ -58,6 +58,10 @@
    the opaque type. --ben
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct lrecord_header
 {
   /* Index into lrecord_implementations_table[].  Objects that have been
@@ -1575,4 +1579,8 @@
 
 #endif /* defined (USE_KKCC) || defined (PDUMP) */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* INCLUDED_lrecord_h_ */
--- a/src/mule-canna.c	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/mule-canna.c	Thu Aug 28 15:44:30 2003 +0000
@@ -169,7 +169,7 @@
 
 /* #### is this global really necessary? */
 #define KEYTOSTRSIZE 2048
-static unsigned char key_buffer[KEYTOSTRSIZE];
+static char key_buffer[KEYTOSTRSIZE];
 static char **warning;
 
 static int canna_empty_info, canna_through_info;
@@ -191,7 +191,7 @@
 
 static int IRCP_context;
 
-static Lisp_Object storeResults (unsigned char *, int, jrKanjiStatus *);
+static Lisp_Object storeResults (char *, int, jrKanjiStatus *);
 static Lisp_Object kanjiYomiList (int, int);
 static Lisp_Object CANNA_mode_keys (void);
 
@@ -222,7 +222,7 @@
 }
 
 static Lisp_Object
-storeResults (unsigned char *buf, int len, jrKanjiStatus *ks)
+storeResults (char *buf, int len, jrKanjiStatus *ks)
 {
   Lisp_Object val = Qnil;
 
@@ -233,27 +233,28 @@
   else
     {
       /* 確定した文字列 (the confirmed string) */
-      Vcanna_kakutei_string = make_string (buf, len);
+      Vcanna_kakutei_string = make_string ((unsigned char *) buf, len);
       val = make_int (len);
       /* 確定した文字列の読みの情報...
 	 (info about the reading of the confirmed string) */
       Vcanna_kakutei_yomi = Vcanna_kakutei_romaji = Qnil;
       if (ks->info & KanjiYomiInfo)
 	{
-	  unsigned char *p = buf + len + 1;
+	  char *p = buf + len + 1;
 	  int yomilen = strlen (p);
 
 	  if (len + yomilen + 1 < KEYTOSTRSIZE)
 	    {
 	      int yomilen2;
 
-	      Vcanna_kakutei_yomi = make_string (p, yomilen); /* 読み
-								 (reading) */
+	      Vcanna_kakutei_yomi =
+		make_string ((unsigned char *) p, yomilen); /* 読み (reading) */
 	      p += yomilen + 1;
 	      yomilen2 = strlen (p);
 	      if (len + yomilen + yomilen2 + 2 < KEYTOSTRSIZE)
 		{
-		  Vcanna_kakutei_romaji = make_string (p, yomilen2);
+		  Vcanna_kakutei_romaji =
+		    make_string ((unsigned char *) p, yomilen2);
 				/* ローマ字 (romanization) */
 		}
 	    }
@@ -309,7 +310,8 @@
       Vcanna_mode_string = Qnil;
       if (ks->info & KanjiModeInfo)
 	{
-	  Vcanna_mode_string = make_string (ks->mode, strlen (ks->mode));
+	  Vcanna_mode_string =
+	    make_string (ks->mode, strlen ((const char *) ks->mode));
 	}
 
       /* その他の情報 (other information) */
@@ -382,7 +384,8 @@
       char servername[256];
 
       CHECK_STRING (server);
-      strncpy (servername, XSTRING_DATA (server), XSTRING_LENGTH (server));
+      strncpy (servername, (const char *) XSTRING_DATA (server),
+	       XSTRING_LENGTH (server));
       servername[XSTRING_LENGTH (server)] = '\0';
       jrKanjiControl (0, KC_SETSERVERNAME, servername);
     }
@@ -396,7 +399,8 @@
       char rcname[256];
 
       CHECK_STRING (rcfile);
-      strncpy (rcname, XSTRING_DATA (rcfile), XSTRING_LENGTH (rcfile));
+      strncpy (rcname, (const char *) XSTRING_DATA (rcfile),
+	       XSTRING_LENGTH (rcfile));
       rcname[XSTRING_LENGTH (rcfile)] = '\0';
       jrKanjiControl (0, KC_SETINITFILENAME, rcname);
     }
@@ -417,14 +421,14 @@
       while (p < q)
 	{
 	  q--;
-	  val = Fcons (make_string (*q, strlen (*q)), val);
+	  val = Fcons (make_string (*q, strlen ((const char *) *q)), val);
 	}
     }
   val = Fcons (val, Qnil);
 
   if (res == -1)
     {
-      val = Fcons (make_string ((unsigned char*) jrKanjiError,
+      val = Fcons (make_string ((unsigned char *) jrKanjiError,
 				strlen (jrKanjiError)), val);
       /* イニシャライズで失敗した場合。 (on initialization failure) */
       return Fcons (Qnil, val);
@@ -477,7 +481,7 @@
     {
       for (p = (unsigned char**) warning ; *p ; p++)
 	{
-	  val = Fcons (make_string (*p, strlen (*p)), val);
+	  val = Fcons (make_string (*p, strlen ((const char *) *p)), val);
 	}
     }
   val = Fcons (val, Qnil);
@@ -506,7 +510,7 @@
 #else /* CANNA_MULE */
   m2c (XSTRING_DATA (str), XSTRING_LENGTH (str), cbuf);
   ks.echoStr = cbuf;
-  ks.length = strlen (cbuf);
+  ks.length = strlen ((const char *) cbuf);
 #endif /* CANNA_MULE */
   ksv.ks = &ks;
   len = jrKanjiControl (0, KC_DEFINEKANJI, (char *)&ksv);
@@ -576,7 +580,8 @@
   ks.length = XSTRING_LENGTH (yomi);
   key_buffer[ks.length] = '\0';
 #else /* CANNA_MULE */
-  m2c (XSTRING_DATA (yomi), XSTRING_LENGTH (yomi), key_buffer);
+  m2c (XSTRING_DATA (yomi), XSTRING_LENGTH (yomi),
+       (unsigned char *) key_buffer);
   ks.length = strlen (key_buffer);
 #endif /* CANNA_MULE */
 
@@ -595,7 +600,8 @@
       ks.mode = (unsigned char *)(key_buffer + XSTRING_LENGTH (yomi) + 1);
 #else /* CANNA_MULE */
       ks.mode = (unsigned char *)(key_buffer + ks.length + 1);
-      m2c (XSTRING_DATA (roma), XSTRING_LENGTH (roma), ks.mode);
+      m2c (XSTRING_DATA (roma), XSTRING_LENGTH (roma),
+	   (unsigned char *) ks.mode);
 #endif /* CANNA_MULE */
     }
 
@@ -652,7 +658,7 @@
   strncpy (key_buffer, XSTRING_DATA (str), XSTRING_LENGTH (str));
   key_buffer[XSTRING_LENGTH (str)] = '\0';
 #else /* CANNA_MULE */
-  m2c (XSTRING_DATA (str), XSTRING_LENGTH (str), key_buffer);
+  m2c (XSTRING_DATA (str), XSTRING_LENGTH (str), (unsigned char *) key_buffer);
 #endif /* CANNA_MULE */
   p = (unsigned char**) key_buffer;
   n = jrKanjiControl (0, KC_PARSE,  (char *) &p);
@@ -660,7 +666,7 @@
   while (n > 0)
     {
       n--;
-      val = Fcons (make_string (p[n], strlen (p[n])), val);
+      val = Fcons (make_string (p[n], strlen ((const char *) p[n])), val);
     }
   return val;
 }
@@ -670,10 +676,10 @@
 */
        ())
 {
-  unsigned char buf[256];
+  char buf[256];
 
   jrKanjiControl (0, KC_QUERYMODE, buf);
-  return make_string (buf, strlen (buf));
+  return make_string ((unsigned char *) buf, strlen (buf));
 }
 
 /*
@@ -743,7 +749,8 @@
 		   (RK_XFER << RK_XFERBITS) | RK_KFER);
 #else /* CANNA_MULE */
   m2c (XSTRING_DATA (yomi), XSTRING_LENGTH (yomi), yomibuf);
-  nbun = RkBgnBun (IRCP_context, (char *) yomibuf, strlen (yomibuf),
+  nbun = RkBgnBun (IRCP_context, (char *) yomibuf,
+		   strlen ((const char *) yomibuf),
 		   (RK_XFER << RK_XFERBITS) | RK_KFER);
 #endif /* CANNA_MULE */
 
@@ -798,7 +805,7 @@
   p = RkBuf;
   for (i = 0 ; i < len ; i++)
     {
-      slen = strlen (p);
+      slen = strlen ((const char *) p);
       if (NILP(res))
 	{
 	  endp = res = Fcons (make_string (p, slen), Qnil);
@@ -1851,7 +1858,7 @@
   unsigned char cbuf[4096];
 
   c2mu (p,l,cbuf);
-  return (make_string (cbuf,strlen (cbuf)));
+  return (make_string (cbuf, strlen ((const char *) cbuf)));
 }
 
 /* return the MULE internal string length of EUC string */
--- a/src/mule-wnnfns.c	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/mule-wnnfns.c	Thu Aug 28 15:44:30 2003 +0000
@@ -361,7 +361,7 @@
       return Qnil;
     }
   size = XSTRING_LENGTH (lname) > 1024 ? 1026 : XSTRING_LENGTH (lname) + 2;
-  envname = ALLOCA (size);
+  envname = (char *) ALLOCA (size);
   strncpy (envname, (char *) XSTRING_DATA (lname), size-2);
   envname[size-2] = '\0';
   if (NILP (hname)) hostname = "";
@@ -370,7 +370,7 @@
       CHECK_STRING (hname);
       size = XSTRING_LENGTH(hname) > 1024 ? 1025 : XSTRING_LENGTH(hname) + 1;
 
-      hostname = ALLOCA (size);
+      hostname = (char *) ALLOCA (size);
       strncpy (hostname, (char *) XSTRING_DATA (hname), size-1);
       hostname[size-1] = '\0';
     }
--- a/src/opaque.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/opaque.h	Thu Aug 28 15:44:30 2003 +0000
@@ -63,8 +63,8 @@
 #define wrap_opaque_ptr(p) wrap_record (p, opaque_ptr)
 #define OPAQUE_PTRP(x) RECORDP (x, opaque_ptr)
 
-MODULE_API Lisp_Object make_opaque_ptr (void *val);
-MODULE_API void free_opaque_ptr (Lisp_Object ptr);
+EXTERN_C MODULE_API Lisp_Object make_opaque_ptr (void *val);
+EXTERN_C MODULE_API void free_opaque_ptr (Lisp_Object ptr);
 
 #define get_opaque_ptr(op) (XOPAQUE_PTR (op)->ptr)
 #define set_opaque_ptr(op, ptr_) (XOPAQUE_PTR (op)->ptr = (ptr_))
--- a/src/process.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/process.h	Thu Aug 28 15:44:30 2003 +0000
@@ -36,6 +36,10 @@
 
 #else /* not NO_SUBPROCESSES */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* struct Lisp_Process is defined in procimpl.h; only process-*.c need
    to know about the guts of it. */
 
@@ -118,6 +122,10 @@
 const char *signal_name (int signum);
 Lisp_Object canonicalize_host_name (Lisp_Object host);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* not NO_SUBPROCESSES */
 
 /* The name of the file open to get a null file, or a data sink.
--- a/src/symeval.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/symeval.h	Thu Aug 28 15:44:30 2003 +0000
@@ -27,6 +27,10 @@
 #ifndef INCLUDED_symeval_h_
 #define INCLUDED_symeval_h_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum symbol_value_type
 {
   /* The following tags use the 'symbol_value_forward' structure
@@ -430,4 +434,8 @@
 
 void flush_all_buffer_local_cache (void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* INCLUDED_symeval_h_ */
--- a/src/text.h	Wed Aug 27 21:52:30 2003 +0000
+++ b/src/text.h	Thu Aug 28 15:44:30 2003 +0000
@@ -45,6 +45,10 @@
 char *strupr (char *);
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* ---------------------------------------------------------------------- */
 /*                     Super-basic character properties                   */
 /* ---------------------------------------------------------------------- */
@@ -2451,6 +2455,10 @@
 #define eilwr(ei) EI_CASECHANGE (ei, 1)
 #define eiupr(ei) EI_CASECHANGE (ei, 0)
 
+#ifdef __cplusplus
+}
+#endif
+
 
 /************************************************************************/
 /*                                                                      */
@@ -2690,6 +2698,10 @@
 };
 typedef enum dfc_conversion_type dfc_conversion_type;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* WARNING: These use a static buffer.  This can lead to disaster if
    these functions are not used *very* carefully.  Another reason to only use
    TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). */
@@ -2897,6 +2909,10 @@
 					   enum new_dfc_src_type type,
 					   Lisp_Object codesys);
 
+#ifdef __cplusplus
+}
+#endif
+
 /* Version of EXTERNAL_TO_C_STRING that *RETURNS* the translated string,
    still in alloca() space.  Requires some trickiness to do this, but gets
    it done! */