Incorrect linkage for C++ functions called from C

Bug #1163719 reported by Michi Henning
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Unity
Phablet
Fix Released
Undecided
Unassigned

Bug Description

In hudclient.cpp, we have:

static void loadingCB(GObject* /*src*/, gpointer dst)
{
    static_cast<HudClient*>(dst)->voiceQueryLoading();
}

// ...

 g_signal_connect(G_OBJECT(m_clientQuery), "voice-query-loading", G_CALLBACK(loadingCB), this);

The loadingCB is passed to GLib as a callback. This is incorrect as it stands. Declaring a function static only controls its visibility, but not its linkage. It happens to work with gcc, but that's coincidental; on other platforms, this may cause a crash.

To specify C linkage, an extern "C" directive is needed. Also, there is no need for the static keyword; instead, the relevant functions can be placed into an anonymous namespace.

Related branches

Changed in unity:
status: New → In Progress
Changed in unity:
status: In Progress → Fix Committed
Michał Sawicz (saviq)
Changed in unity:
status: Fix Committed → Confirmed
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:unity/phablet at revision 546, scheduled for release in unity, milestone 13.05

Changed in unity:
status: Confirmed → Fix Committed
Stephen M. Webb (bregma)
no longer affects: unity
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.