]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Make libltdl work when compiled with a C++ compiler.
authorGeorge Bosilca <bosilca@cs.utk.edu>
Mon, 4 Sep 2006 17:27:27 +0000 (17:27 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Mon, 4 Sep 2006 17:27:27 +0000 (17:27 +0000)
* libltdl/lt__alloc.c, libltdl/lt_dlloader.c, libltdl/ltdl.c,
libltdl/slist.c, libltdl/libltdl/lt__alloc.h,
libltdl/libltdl/lt_error.h, libltdl/libltdl/slist.h,
libltdl/loaders/dld_link.c, libltdl/loaders/dlopen.c,
libltdl/loaders/dyld.c, libltdl/loaders/load_add_on.c,
libltdl/loaders/loadlibrary.c, libltdl/loaders/preopen.c,
libltdl/loaders/shl_load.c, tests/stresstest.at,
tests/testsuite.at, tests/f77demo/foo.h, tests/fcdemo/foo.h,
tests/mdemo/foo.h, tests/mdemo/foo1.c, tests/mdemo/foo2.c,
tests/mdemo/main.c: Allow sources to be compiled by a C++
compiler: Cast appropriately, add C linkage for `get_vtable'
functions, do not use C++ keyword `delete'.

23 files changed:
ChangeLog
libltdl/libltdl/lt__alloc.h
libltdl/libltdl/lt_error.h
libltdl/libltdl/slist.h
libltdl/loaders/dld_link.c
libltdl/loaders/dlopen.c
libltdl/loaders/dyld.c
libltdl/loaders/load_add_on.c
libltdl/loaders/loadlibrary.c
libltdl/loaders/preopen.c
libltdl/loaders/shl_load.c
libltdl/lt__alloc.c
libltdl/lt_dlloader.c
libltdl/ltdl.c
libltdl/slist.c
tests/f77demo/foo.h
tests/fcdemo/foo.h
tests/mdemo/foo.h
tests/mdemo/foo1.c
tests/mdemo/foo2.c
tests/mdemo/main.c
tests/stresstest.at
tests/testsuite.at

index 3802108772a6c3a58fd3b1dadb57eea248670381..73ad66038139c1b493d71a78c6b7ef482ebfeef4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,21 @@
 2006-09-04  George Bosilca <bosilca@cs.utk.edu>
        and Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
 
+       Make libltdl work when compiled with a C++ compiler.
+
+       * libltdl/lt__alloc.c, libltdl/lt_dlloader.c, libltdl/ltdl.c,
+       libltdl/slist.c, libltdl/libltdl/lt__alloc.h,
+       libltdl/libltdl/lt_error.h, libltdl/libltdl/slist.h,
+       libltdl/loaders/dld_link.c, libltdl/loaders/dlopen.c,
+       libltdl/loaders/dyld.c, libltdl/loaders/load_add_on.c,
+       libltdl/loaders/loadlibrary.c, libltdl/loaders/preopen.c,
+       libltdl/loaders/shl_load.c, tests/stresstest.at,
+       tests/testsuite.at, tests/f77demo/foo.h, tests/fcdemo/foo.h,
+       tests/mdemo/foo.h, tests/mdemo/foo1.c, tests/mdemo/foo2.c,
+       tests/mdemo/main.c: Allow sources to be compiled by a C++
+       compiler: Cast appropriately, add C linkage for `get_vtable'
+       functions, do not use C++ keyword `delete'.
+
        * libltdl/config/ltmain.m4sh (func_mode_link): In the dlsym
        file, define a type for the symbol list, and declare the list
        `extern', so that it is extern even if compiled by a C++
index b5c615715a1eb1ec6525d4995d1b94802e7d1a70..6f95109fd3d88517ce8016105f110fac0817cdca 100644 (file)
@@ -37,7 +37,7 @@ LT_BEGIN_C_DECLS
 #define MALLOC(tp, n)          (tp*) lt__malloc((n) * sizeof(tp))
 #define REALLOC(tp, mem, n)    (tp*) lt__realloc((mem), (n) * sizeof(tp))
 #define FREE(mem)                                      LT_STMT_START { \
-       if (mem) (mem) = (free ((void *)mem), (void *) 0);      } LT_STMT_END
+       if (mem) { free ((void *)mem); mem = NULL; }    } LT_STMT_END
 #define MEMREASSIGN(p, q)                              LT_STMT_START { \
        if ((p) != (q)) { if (p) free (p); (p) = (q); (q) = 0; }        \
                                                                } LT_STMT_END
index 8773770a493078897fcd53c09e7b6a70b7cbd245..8e417469e3a2e79e72d650db382a0c99a46a3679 100644 (file)
@@ -69,8 +69,8 @@ enum {
        LT_ERROR_MAX
 };
 
-/* Should be max of the error string lengths above */
-#define LT_ERROR_LEN_MAX (35)
+/* Should be max of the error string lengths above (plus one for C++) */
+#define LT_ERROR_LEN_MAX (36)
 
 /* These functions are only useful from inside custom module loaders. */
 LT_SCOPE int   lt_dladderror   (const char *diagnostic);
index 4b47cda6d3f3dee0f4005d96b626d63f73982472..80a570fb88263edb85f19d86fb723c981c9ea4ce 100644 (file)
@@ -63,7 +63,7 @@ typedef int   SListCompare    (const SList *item1, const SList *item2,
 LT_SCOPE SList *slist_concat   (SList *head, SList *tail);
 LT_SCOPE SList *slist_cons     (SList *item, SList *slist);
 
-LT_SCOPE SList *slist_delete   (SList *slist, void (*delete) (void *item));
+LT_SCOPE SList *slist_delete   (SList *slist, void (*delete_fct) (void *item));
 LT_SCOPE void *        slist_remove    (SList **phead, SListCallback *find,
                                 void *matchdata);
 LT_SCOPE SList *slist_reverse  (SList *slist);
index b93868d201c60c7a5c7e74531e82d4ff100c2318..c7b283e23b1c7011b4cf869b4a9440f7a58923b1 100644 (file)
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dld_link_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
index 95e7a07a8e468af047026bedd91cb68d2f7e9b49..3bd5bd3f7cf85693f9b2fc71b3980bb1ef9e5909 100644 (file)
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dlopen_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -56,7 +58,7 @@ get_vtable (lt_user_data loader_data)
 
   if (!vtable)
     {
-      vtable = lt__zalloc (sizeof *vtable);
+      vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
     }
 
   if (vtable && !vtable->name)
index c5f94f069a63b25f8f096f50e3b293123288b270..2138de6cf9e65c092f467beef812e38e59555a8c 100644 (file)
@@ -1,5 +1,5 @@
 /* loader-dyld.c -- dynamic linking on darwin and OS X
-   Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
    Originally by Peter O'Gorman <peter@pogma.com>
 
    NOTE: The canonical source of this file is maintained with the
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dyld_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
index d67e3a20d4345e31a6b4e8eb5ef4ffc4bc3bc44f..03a1557982d9e36d747fa9b86e7c4654f1ddcda0 100644 (file)
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     load_add_on_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
index 47b0e664b68b324c70971e6b14a845cbbd9eef95..49a33ec6c05bb88de78853c2002a3683f1d0eb3c 100644 (file)
@@ -1,5 +1,5 @@
 /* loader-loadlibrary.c --  dynamic linking for Win32
-   Copyright (C) 1998, 1999, 2000, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006 Free Software Foundation, Inc.
    Originally by Thomas Tanner <tanner@ffii.org>
 
    NOTE: The canonical source of this file is maintained with the
@@ -40,7 +40,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     loadlibrary_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -62,7 +64,7 @@ get_vtable (lt_user_data loader_data)
 
   if (!vtable)
     {
-      vtable = lt__zalloc (sizeof *vtable);
+      vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
       iface_id = lt_dlinterface_register ("ltdl loadlibrary", NULL);
     }
 
@@ -202,7 +204,7 @@ vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
 {
   int errors = 0;
 
-  if (FreeLibrary(module) == 0)
+  if (FreeLibrary((HMODULE) module) == 0)
     {
       LT__SETERROR (CANNOT_CLOSE);
       ++errors;
@@ -217,7 +219,7 @@ vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
 static void *
 vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char *name)
 {
-  void *address = GetProcAddress (module, name);
+  void *address = (void *) GetProcAddress ((HMODULE) module, name);
 
   if (!address)
     {
index e71c46f2dbfe8a5153b588a9a54cf273c9e04e2c..dc2e9268063cfe415af9fee636cc148912ac0128 100644 (file)
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     preopen_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -58,7 +60,7 @@ get_vtable (lt_user_data loader_data)
 
   if (!vtable)
     {
-      vtable = lt__zalloc (sizeof *vtable);
+      vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable);
     }
 
   if (vtable && !vtable->name)
@@ -259,7 +261,7 @@ add_symlist (const lt_dlsymlist *symlist)
   /* Don't add the same list twice:  */
   if (!lists)
     {
-      symlist_chain *tmp = lt__zalloc (sizeof *tmp);
+      symlist_chain *tmp = (symlist_chain *) lt__zalloc (sizeof *tmp);
 
       if (tmp)
        {
index bcdbc5632c522d2f5e4757eb6e2925e3ae86c52c..e5d0e35f6972a8e028f115c21bca852fb548232e 100644 (file)
@@ -36,7 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     shl_load_LTX_get_vtable
 
+LT_BEGIN_C_DECLS
 LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data);
+LT_END_C_DECLS
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
index 019e5e3869f69098316aaf9656de40b5e752c8ba..7cb8553b0458292a8b5c3cc61009448e2653f63c 100644 (file)
@@ -97,5 +97,5 @@ lt__memdup (void const *mem, size_t n)
 char *
 lt__strdup (const char *string)
 {
-  return lt__memdup (string, strlen (string) +1);
+  return (char *) lt__memdup (string, strlen (string) +1);
 }
index 411b5e010c859fe8b1b1269e73eb4e5be831b372..d8317dfd4c66000f15762cda0f62e73ab3ecdbf0 100644 (file)
@@ -46,8 +46,8 @@ static        SList    *loaders               = 0;
 static void *
 loader_callback (SList *item, void *userdata)
 {
-  const lt_dlvtable *vtable = item->userdata;
-  const char *     name    = userdata;
+  const lt_dlvtable *vtable = (const lt_dlvtable *) item->userdata;
+  const char *     name    = (const char *) userdata;
 
   assert (vtable);
 
@@ -111,7 +111,7 @@ lt_dlloader_next (lt_dlloader loader)
 const lt_dlvtable *
 lt_dlloader_get        (lt_dlloader loader)
 {
-  return loader ? ((SList *) loader)->userdata : 0;
+  return (const lt_dlvtable *) (loader ? ((SList *) loader)->userdata : 0);
 }
 
 
@@ -155,7 +155,8 @@ lt_dlloader_remove (char *name)
     }
 
   /* If we got this far, remove the loader from our global list.  */
-  return slist_unbox (slist_remove (&loaders, loader_callback, name));
+  return (lt_dlvtable *)
+      slist_unbox ((SList *) slist_remove (&loaders, loader_callback, name));
 }
 
 
index 0e57473b14ee099178879326351ced6231dd82b7..46badfb3ed89f8e901ccbabf9ed9620dbb53fc5d 100644 (file)
@@ -159,7 +159,8 @@ lt__alloc_die_callback (void)
 static int
 loader_init_callback (lt_dlhandle handle)
 {
-  return loader_init (lt_dlsym (handle, "get_vtable"), 0);
+  lt_get_vtable *vtable_func = (lt_get_vtable *) lt_dlsym (handle, "get_vtable");
+  return loader_init (vtable_func, 0);
 }
 #endif /* HAVE_LIBDLLOADER */
 
@@ -195,7 +196,9 @@ loader_init (lt_get_vtable *vtable_func, lt_user_data data)
 #define get_vtable             preopen_LTX_get_vtable
 #define preloaded_symbols      LT_CONC3(lt_, LTDLOPEN, _LTX_preloaded_symbols)
 
+LT_BEGIN_C_DECLS
 LT_SCOPE const lt_dlvtable *   get_vtable (lt_user_data data);
+LT_END_C_DECLS
 #ifdef HAVE_LIBDLLOADER
 extern lt_dlsymlist            preloaded_symbols;
 #endif
@@ -289,9 +292,9 @@ lt_dlexit (void)
        }
 
       /* close all loaders */
-      for (loader = lt_dlloader_next (NULL); loader;)
+      for (loader = (lt_dlloader *) lt_dlloader_next (NULL); loader;)
        {
-         lt_dlloader *next   = lt_dlloader_next (loader);
+         lt_dlloader *next   = (lt_dlloader *) lt_dlloader_next (loader);
          lt_dlvtable *vtable = (lt_dlvtable *) lt_dlloader_get (loader);
 
          if ((vtable = lt_dlloader_remove ((char *) vtable->name)))
@@ -340,7 +343,7 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename)
       goto done;
     }
 
-  handle = *phandle;
+  handle = (lt__handle *) *phandle;
   if (filename)
     {
       /* Comment out the check of file permissions using access.
@@ -371,7 +374,7 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename)
     const lt_dlvtable *vtable = 0;
     lt_dlloader *loader = 0;
 
-    while ((loader = lt_dlloader_next (loader)))
+    while ((loader = (lt_dlloader *) lt_dlloader_next (loader)))
       {
        vtable = lt_dlloader_get (loader);
        handle->module = (*vtable->module_open) (vtable->dlloader_data,
@@ -1321,7 +1324,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename)
       ((lt__handle *) *phandle)->info.ref_count        = 1;
       MEMREASSIGN (((lt__handle *) *phandle)->info.name, name);
 
-      ((lt__handle *) *phandle)->next  = handles;
+      ((lt__handle *) *phandle)->next  = (lt__handle *) handles;
       handles                          = *phandle;
     }
 
@@ -2033,7 +2036,7 @@ typedef struct {
 lt_dlinterface_id
 lt_dlinterface_register (const char *id_string, lt_dlhandle_interface *iface)
 {
-  lt__interface_id *interface_id = lt__malloc (sizeof *interface_id);
+  lt__interface_id *interface_id = (lt__interface_id *) lt__malloc (sizeof *interface_id);
 
   /* If lt__malloc fails, it will LT__SETERROR (NO_MEMORY), which
      can then be detected with lt_dlerror() if we return 0.  */
index 8cd855183bff7dd4d0039f09bfb1b1e6115810a0..84af3f1d83dc1a8e03df94608f9b7252e6363a40 100644 (file)
@@ -48,14 +48,14 @@ static SList *      slist_sort_merge    (SList *left, SList *right,
        ...
 */
 SList *
-slist_delete (SList *head, void (*delete) (void *item))
+slist_delete (SList *head, void (*delete_fct) (void *item))
 {
-  assert (delete);
+  assert (delete_fct);
 
   while (head)
     {
       SList *next = head->next;
-      (*delete) (head);
+      (*delete_fct) (head);
       head = next;
     }
 
@@ -340,7 +340,7 @@ slist_sort (SList *slist, SListCompare *compare, void *userdata)
 SList *
 slist_box (const void *userdata)
 {
-  SList *item = malloc (sizeof *item);
+  SList *item = (SList *) malloc (sizeof *item);
 
   if (item)
     {
index 1468912b455fcb27d648fa183b3c1e6f2285798c..b39255a48d3ce6aaa6a69bb784f3398fc4ce077f 100644 (file)
@@ -1,5 +1,5 @@
 /* foo.h -- interface to fortran and C libraries
-   Copyright (C) 1998-1999 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2006 Free Software Foundation, Inc.
    This file is part of GNU Libtool.
 
 This program is free software; you can redistribute it and/or modify
@@ -41,7 +41,10 @@ extern int fwrapper(int);
  * Note that fortran passes args by reference, so
  * you need to provide pointers to your ints.
  */
-extern void F77_FUNC(fsub,FSUB)(int *arg, int *res);
-
+extern
+#ifdef __cplusplus
+"C"
+#endif
+void F77_FUNC(fsub,FSUB)(int *arg, int *res);
 
 #endif
index e62e004933924e12ab25a89bb99f3810e0182ec0..9fd4103510d30cee59a19afbea8cf1efb9d5db0d 100644 (file)
@@ -41,7 +41,11 @@ extern int fwrapper(int);
  * Note that fortran passes args by reference, so
  * you need to provide pointers to your ints.
  */
-extern void FC_FUNC(fsub,FSUB)(int *arg, int *res);
+extern
+#ifdef __cplusplus
+"C"
+#endif
+void FC_FUNC(fsub,FSUB)(int *arg, int *res);
 
 
 #endif
index 106f937b8c82748958ebe4da248f481a4386c496..59eac5e23ce3411603bbee6556635d24b0a443bb 100644 (file)
@@ -1,5 +1,5 @@
 /* foo.h -- interface to the libfoo* libraries
-   Copyright (C) 1998-1999 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2006 Free Software Foundation, Inc.
    Originally by Thomas Tanner <tanner@ffii.org>
    This file is part of GNU Libtool.
 
@@ -22,6 +22,19 @@ USA. */
 #ifndef _FOO_H_
 #define _FOO_H_ 1
 
+/* __BEGIN_DECLS should be used at the beginning of your declarations,
+   so that C++ compilers don't mangle their names.  Use __END_DECLS at
+   the end of C declarations. */
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS /* empty */
+#endif
+
 /* Silly constants that the functions return. */
 #define HELLO_RET 0xe110
 #define FOO_RET 0xf00
index c7300c0b7af371db18e92b1cd455a6d69fc4def9..0f960eb3819600721dfc4c38ba13553b0ba1d7a3 100644 (file)
@@ -41,6 +41,7 @@ _foo1_helper()
 }
 
 /* exported functions */
+__BEGIN_DECLS
 
 int
 foo1()
@@ -55,3 +56,5 @@ hello()
   printf ("** This is foolib 1 **\n");
   return HELLO_RET;
 }
+
+__END_DECLS
index d1d85d5eb0b676fd1335fbd6c7269fb30c69ef5d..301e3cb10eb99b02ed338ca34aff6e881cfc3d3c 100644 (file)
@@ -41,6 +41,7 @@ _foo2_helper()
 }
 
 /* exported functions */
+__BEGIN_DECLS
 
 int
 foo2()
@@ -55,3 +56,5 @@ hello()
   printf ("** This is foolib 2 **\n");
   return HELLO_RET;
 }
+
+__END_DECLS
index 38524f0ffbec949fb60754925c485497c1f8d37e..a73caac88dd4abac72d3461967bf152c0e0a7138 100644 (file)
@@ -23,6 +23,10 @@ USA. */
 #include <stdio.h>
 #include <string.h>
 
+LT_BEGIN_C_DECLS
+extern int myfunc (void);
+LT_END_C_DECLS
+
 int
 test_dl (char *filename)
 {
index af06d251aa63ff7f03f15e44272c1ee5928ef899..4f7abaf651e779f11e08685f2856f163543c1b5b 100644 (file)
@@ -30,10 +30,17 @@ mkdir sub sub2 sub3 2>/dev/null
 
 AT_DATA(a.c,
 [[/* all kinds of data items */
+#ifdef __cplusplus
+extern "C" {
+#endif
 int v1;
 static int v2;
 int v3 = 0;
 int v4 = 1;
+extern const int v5, v6;
+extern const char *v7;
+extern const char v8[];
+extern int (*const v12) (void);
 const int v5 = 0;
 const int v6 = 1;
 const char* v7 = "\01foo";
@@ -47,6 +54,9 @@ typedef struct { int arr[1000]; } large;
 large v13;
 large v14 = { { 0 } };
 large v15 = { { 1 } };
+#ifdef __cplusplus
+}
+#endif
 ]])
 
 AT_DATA(asyms,
@@ -73,7 +83,11 @@ int ab = 1;
 ]])
 
 AT_DATA(main.c,
-[[extern int v1;
+[[
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int v1;
 extern int v3, v4;
 extern const int v5, v6;
 extern const char* v7;
@@ -82,6 +96,9 @@ extern int v9(void);
 extern int (*v10) (void);
 extern int (*v11) (void);
 extern int (*const v12) (void);
+#ifdef __cplusplus
+}
+#endif
 
 typedef struct { int arr[1000]; } large;
 extern large v13, v14, v15;
@@ -96,7 +113,10 @@ int main(void)
 ]])
 
 AT_DATA(dlself.c,
-[[extern int v1;
+[[#ifdef __cplusplus
+extern "C" {
+#endif
+extern int v1;
 extern int v3, v4;
 extern const int v5, v6;
 extern const char* v7;
@@ -119,6 +139,9 @@ extern int (*w10) (void);
 extern int (*w11) (void);
 extern int (*const w12) (void);
 extern large w13, w14, w15;
+#ifdef __cplusplus
+}
+#endif
 
 int main(void)
 {
@@ -131,6 +154,9 @@ int main(void)
 }
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 int w1;
 static int w2;
 int w3 = 0;
@@ -146,6 +172,9 @@ int (*const w12) (void) = w9;
 large w13;
 large w14 = { { 0 } };
 large w15 = { { 1 } };
+#ifdef __cplusplus
+}
+#endif
 ]])
 
 AT_DATA(dlselfsyms,
index ab11e5c689b6e74438cc6de4d01156609d412087..da39d3171782a2ae3beb4720e5d8471f92a1e5c7 100644 (file)
@@ -167,7 +167,10 @@ AT_CHECK([test -n "[$]$1" || (exit 77)])
 # is omitted, then no Makefile is created.
 m4_define([_LTDL_PROJECT_FILES],
 [AT_DATA([module.c],
-[[const char *
+[[#ifdef __cplusplus
+extern "C"
+#endif
+const char *
 hello (void)
 {
   return "Hello!";