_XiGetDevicePresenceNotifyEvent can't be used from C++

Bug #373711 reported by Alberto Milone
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libxi (Ubuntu)
Fix Released
Medium
Alberto Milone
Jaunty
Fix Released
Undecided
Unassigned
Karmic
Fix Released
Medium
Alberto Milone

Bug Description

Binary package hint: libxi-dev

Architecture: any
Distro: Ubuntu 9.04

If I call the DevicePresence() function (in XInput.h) from C++ I get the following error:
undefined reference to `_XiGetDevicePresenceNotifyEvent(_XDisplay*)'

TEST CASE:
 install libxi-dev
 create a new C++ program
 include XInput.h
 call the DevicePresence() function
 try to compile the program

NOTE: it works well using C

Upstream has the fix already:
http://cgit.freedesktop.org/xorg/lib/libXi/tree/include/X11/extensions/XInput.h#n160

Changed in libxi (Ubuntu):
assignee: nobody → Alberto Milone (albertomilone)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Alberto Milone (albertomilone) wrote :

SRU Request:
I have cherrypicked the fix from upstream and it works for me. Please accept in in jaunty-proposed.

Use case:
It should be possible to catch Xinput events from C++ as we do in C.

Revision history for this message
Alberto Milone (albertomilone) wrote :

Sorry, there was a mistake in the previous debdiff which said "jaunty" instead of "jaunty-proposed" in the changelog. Please use this debdiff instead.

Revision history for this message
Alberto Milone (albertomilone) wrote :

This debdiff uses a correct revision (-1ubuntu1.1) in the changelog.

Revision history for this message
Martin Pitt (pitti) wrote :

Please add a standard SRU description to this bug, see https://wiki.ubuntu.com/StableReleaseUpdates.

In particular, is this a regression? How does it manifest to an user? How serious is it? It needs to match the SRU criteria.

Revision history for this message
Martin Pitt (pitti) wrote :

Also, please fix in karmic first.

Changed in libxi (Ubuntu Jaunty):
status: New → Incomplete
Changed in libxi (Ubuntu Karmic):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libxi - 2:1.2.0-1ubuntu2

---------------
libxi (2:1.2.0-1ubuntu2) karmic; urgency=low

  [ Alberto Milone ]
  * debian/patches/101_fix_devicepresence_declaration_cplusplus.diff:
    - Use extern "C" in the declaration for DevicePresence (in
      XInput.h) so that it can be accessed from C++ (LP: #373711).

 -- Alberto Milone <email address hidden> Fri, 08 May 2009 17:05:49 +0200

Changed in libxi (Ubuntu Karmic):
status: Fix Committed → Fix Released
description: updated
Revision history for this message
Alberto Milone (albertomilone) wrote :

Let me rephrase my request.

SRU: minimal patch for Jaunty is attached (see comment 3)

Nominating for SRU, fulfills: (1) have an obviously safe patch

The patch modifies only a header file so that extern "C" is used when developers include the header in a C++ program. This condition is tested with #if defined(__cplusplus) || defined(c_plusplus).

This change doesn't affect programs written in C, is definitely safe and will make C++ developers' life a little better.

The fix is from upstream and has been verified in Jaunty.

TEST CASE:
 install libxi-dev
 create a new C++ program
 include XInput.h
 call the DevicePresence() function
 try to compile the program
 notice the compilation error

Revision history for this message
Martin Pitt (pitti) wrote :

Accepted libxi into jaunty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in libxi (Ubuntu Jaunty):
status: Incomplete → Fix Committed
tags: added: verification-needed
Revision history for this message
Alberto Milone (albertomilone) wrote :

I can confirm that the package in jaunty-proposed solves the problem. I can compile my program without getting the error.

Revision history for this message
Alberto Milone (albertomilone) wrote :

To test the fix you can get the following source:
http://albertomilone.com/ubuntu/touchpad/daemon/x-bus_0.1-0ubuntu1.dsc
http://albertomilone.com/ubuntu/touchpad/daemon/x-bus_0.1-0ubuntu1.diff.gz
http://albertomilone.com/ubuntu/touchpad/daemon/x-bus_0.1.orig.tar.gz

I created two distinct environment with pbuilder (one with jaunty-updates and the other with jaunty-proposed) and tried to build the same package.

Build log with jaunty-updates:
http://albertomilone.com/ubuntu/touchpad/daemon/stable.txt

Build log with jaunty-proposed:
http://albertomilone.com/ubuntu/touchpad/daemon/proposed.txt

As you can see in the 2nd log, the package builds only with my fix in -proposed.
and you can try to build it with the fix and without the fix.

Martin Pitt (pitti)
tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libxi - 2:1.2.0-1ubuntu1.1

---------------
libxi (2:1.2.0-1ubuntu1.1) jaunty-proposed; urgency=low

  [ Alberto Milone ]
  * debian/patches/101_fix_devicepresence_declaration_cplusplus.diff:
    - Use extern "C" in the declaration for DevicePresence (in
      XInput.h) so that it can be accessed from C++ (LP: #373711).

 -- Alberto Milone <email address hidden> Thu, 14 May 2009 11:10:53 +0200

Changed in libxi (Ubuntu Jaunty):
status: Fix Committed → Fix Released
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.