[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 120895] Functions declared extern "C" in xsldbgmsg.h but not
From:       The Written Word <bugzilla-kde () thewrittenword ! com>
Date:       2006-01-31 19:05:36
Message-ID: 20060131190536.6018.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
         
http://bugs.kde.org/show_bug.cgi?id=120895         




------- Additional Comments From bugzilla-kde thewrittenword com  2006-01-31 20:05 -------
I emailed the HP-UX C++ developer mailing list. Here's what they said:
 >This is a subtle one that we see fairly often.  The problem is that
 >there are two functions xsldbgSetAppFunc with different types.  The
 >first (the declaration) has a parameter of type

 >*notifyXsldbgAppFunc) (XsldbgMessageEnum type, const void *data)

 >and that parameter has C linkage.  The second (the definition, which
 >ends up being mangled) has a parameter of type:

 >*notifyXsldbgAppFunc) (XsldbgMessageEnum type, const void *data)
   
 >but that parameter has C++ linkage.  Since this is recognized as a
 >different function because of the difference in parameter, and is not
 >itself enclosed in an extern "C" block, it is mangled.

 >To get these to match, you need to define a type for the parameter
 >which has C linkage and use it in both places, or place the entire
 >definition in an extern "C" block, if that will fork for your actual
 >situation.

This reply was based on a small code-snippet I created to explain the problem:
  typedef enum {
    XSLDBG_MSG_THREAD_NOTUSED,
    XSLDBG_MSG_THREAD_INIT
  } XsldbgMessageEnum;

  extern "C" {
    void xsldbgSetAppFunc (int (*notifyXsldbgAppFunc) (XsldbgMessageEnum type,
  }

  static int (*notifyXsldbgAppFuncPtr) (XsldbgMessageEnum type,
                                        const void *data) = 0;

  void xsldbgSetAppFunc (int (*notifyXsldbgAppFunc) (XsldbgMessageEnum type,
                                                     const void *data)) {
    notifyXsldbgAppFuncPtr = notifyXsldbgAppFunc;
  }

I reworked this snippet based on the reply to:
  typedef enum {
    XSLDBG_MSG_THREAD_NOTUSED,
    XSLDBG_MSG_THREAD_INIT
  } XsldbgMessageEnum;

  extern "C" {
  typedef int (*notifyXsldbgAppFuncType) (XsldbgMessageEnum type,
                                          const void *data);
  void xsldbgSetAppFunc (notifyXsldbgAppFuncType notifyXsldbgAppFunc);
  }

  static notifyXsldbgAppFuncType notifyXsldbgAppFuncPtr = 0;

  void xsldbgSetAppFunc (notifyXsldbgAppFuncType notifyXsldbgAppFunc) {
    notifyXsldbgAppFuncPtr = notifyXsldbgAppFunc;
  }

I can rework the patch if you want with the new typedef.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic