Bug 830

Summary: /usr/include/X11/extensions/dpms.h + xpm.h cannot be used in C++ code
Product: xorg Reporter: Kevin DeKorte <kdekorte>
Component: Lib/otherAssignee: Roland Mainz <roland.mainz>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high CC: alan.coopersmith, kem, mharris, roland.mainz
Version: 6.7.0   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
patch for dpms.h to compile with C++ code
none
Alternate patch that uses _XFUNCPROTOBEGIN and _XFUNCPROTOEND
none
Patch for xpm.h to use _XFUNCPROTOBEGIN and _XFUNCPROTOEND
none
Corrected version of xpm.h.patch
none
[FIXED_X11R68x] Final patch for X11/extensions/dpms.h (patch for 2004-12-06-trunk)
roland.mainz: 6.8-branch+
[FIXED_X11R68x] xpm.h diff including Changelog, patch for 2004-12-07-trunk roland.mainz: 6.8-branch+

Description Kevin DeKorte 2004-07-06 08:49:11 UTC
When using dpms.h in a C++ program. The code is compiled and linked
correctly, but when the program is ran the DPMS symbols have been
mangled by C++ and the DPMS* functions can't be located and the
program crashes. Suggest putting and #ifdef __cplusplus extern "C" in
the dpms.h header to correct this problem.

Example from xpm.h, which works correctly with C++

#ifdef __cplusplus
extern "C" {
#endif


Version-Release number of selected component (if applicable):
xorg-x11-devel-6.7.0-2

How reproducible:
Always

Steps to Reproduce:
1. create a c++ program that uses DPMSQueryExtension
2. compile and link program
3. execute program
    

Actual Results:   relocation error: 
undefined symbol: _Z18DPMSQueryExtensionP9_XDisplayPiS1_


Expected Results:  Program should execute correctly.

Additional info:

When compiling against C code the program works correctly.

In my program I did this and it solved the problem

#ifdef DPMSExtension
#include <X11/Xlib.h>
#ifndef DPMS_SERVER

#include <X11/X.h>
#include <X11/Xmd.h>

extern "C" Bool DPMSQueryExtension(Display *, int *, int *);
extern "C" Bool DPMSCapable(Display *);
extern "C" Status DPMSInfo(Display *, CARD16 *, BOOL *);
extern "C" Status DPMSEnable(Display *);
#endif
#endif

See Fedora Core 2 bug 125979
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=125979
Comment 1 Mike A. Harris 2004-07-07 00:16:29 UTC
Wrong component... "xserver" is not X.Org.

Reassigning to xorg component.
Comment 2 Mike A. Harris 2004-09-01 04:45:01 UTC
Does anyone have comments on this issue?
Comment 3 Kevin DeKorte 2004-09-01 19:52:10 UTC
Created attachment 811 [details] [review]
patch for dpms.h to compile with C++ code

This patch fixes compilation with C++ code. So that code is correctly
identified as C code. Much like the xpm.h header file.
Comment 4 Roland Mainz 2004-09-01 19:59:41 UTC
Comment on attachment 811 [details] [review]
patch for dpms.h to compile with C++ code

Isn't it sufficient to use |_XFUNCPROTOBEGIN| and |_XFUNCPROTOEND| like used in
all the other X11 header files ?
Comment 5 Kevin DeKorte 2004-09-02 07:24:45 UTC
Created attachment 815 [details] [review]
Alternate patch that uses _XFUNCPROTOBEGIN and _XFUNCPROTOEND

Same patch, but it uses _XFUNCPROTOBEGIN and _XFUNCPROTOEND instead of the
#ifdef __cplusplus
Comment 6 Roland Mainz 2004-09-02 09:54:06 UTC
Comment on attachment 815 [details] [review]
Alternate patch that uses _XFUNCPROTOBEGIN and _XFUNCPROTOEND

The patch looks fine for me...

Nit:
Is it possible to fix xpm.h, too (e.g. replace the "manual" |extern "C"| with
_XFUNCPROTOBEGIN and _XFUNCPROTOEND) ?
Comment 7 Kevin DeKorte 2004-09-02 10:24:53 UTC
Created attachment 816 [details] [review]
Patch for xpm.h to use _XFUNCPROTOBEGIN and _XFUNCPROTOEND

Patch for xpm.h to use _XFUNCPROTOBEGIN and _XFUNCPROTOEND. 

This was requested by Roland.
Comment 8 Kevin DeKorte 2004-09-02 10:31:07 UTC
Comment on attachment 816 [details] [review]
Patch for xpm.h to use _XFUNCPROTOBEGIN and _XFUNCPROTOEND

This is defective
Comment 9 Kevin DeKorte 2004-09-02 10:32:12 UTC
Created attachment 817 [details] [review]
Corrected version of xpm.h.patch

Previous patch had a bug in it. This should fix it.
Comment 10 Roland Mainz 2004-09-02 13:07:41 UTC
Kevin:
Can we take both patches for the release (assuming that I and Alan Coopersmith
verify that the patch works on Linux/Solaris) ?
Comment 11 Kevin DeKorte 2004-09-02 13:10:11 UTC
Roland,

You make the patches and do what you want with them. I am not holding any
license or other restriction on them other than the normal xorg license.

Kevin
Comment 12 Kevin E. Martin 2004-09-02 13:16:43 UTC
Roland et al., the 6.8 release is now frozen for all but documentation changes.
These fixes can go in after we cut the 6.8 release.
Comment 13 Roland Mainz 2004-09-02 13:35:05 UTC
Kevin DeKorte wrote:
> You make the patches and do what you want with them. I am not holding any
> license or other restriction on them other than the normal xorg license.

Oh... we have two Kevins here... :)
I was thinking about Kevin Martin in this case since he is the release manager
for X11R6.8 and he decides what goes "in" into the "frozen" tree and what not.
Comment 14 Roland Mainz 2004-09-02 13:38:11 UTC
Kevin E. Martin wrote:
> Roland et al., the 6.8 release is now frozen for all but documentation 
> changes.

I know, but AFAIK you are allowed to make exceptions from the rule (the changes
seems to be trivial with low risk) ... but on the other side the final release
canidate already has been cut so even those changes may be to "risky"...

> These fixes can go in after we cut the 6.8 release.

Agreed.
Comment 15 Roland Mainz 2004-12-07 14:42:40 UTC
Taking bug myself to get some action here...
Comment 16 Roland Mainz 2004-12-07 15:34:33 UTC
Created attachment 1492 [details] [review]
[FIXED_X11R68x] Final patch for X11/extensions/dpms.h (patch for 2004-12-06-trunk)
Comment 17 Roland Mainz 2004-12-07 15:38:51 UTC
Attachment #1492 [details] checked-in:

/cvs/xorg/xc/ChangeLog,v  <--  ChangeLog
new revision: 1.581; previous revision: 1.580
/cvs/xorg/xc/include/extensions/dpms.h,v  <--  dpms.h
new revision: 1.3; previous revision: 1.2
Mailing the commit message to xorg-commit@lists.freedesktop.org...
Comment 18 Roland Mainz 2004-12-07 17:15:20 UTC
Created attachment 1493 [details] [review]
[FIXED_X11R68x] xpm.h diff including Changelog, patch for 2004-12-07-trunk
Comment 19 Roland Mainz 2004-12-07 17:17:51 UTC
Attachment #1493 [details] checked-in:

/cvs/xorg/xc/ChangeLog,v  <--  ChangeLog
new revision: 1.582; previous revision: 1.581
/cvs/xorg/xc/extras/Xpm/lib/xpm.h,v  <--  xpm.h
new revision: 1.3; previous revision: 1.2
Mailing the commit message to xorg-commit@lists.freedesktop.org...

Both fixes checked-in into Xorg trunk, marking bug as FIXED.
Comment 20 Roland Mainz 2004-12-07 17:20:03 UTC
Comment on attachment 1492 [details] [review]
[FIXED_X11R68x] Final patch for X11/extensions/dpms.h (patch for 2004-12-06-trunk)

Requesting approval for X11R6.8.x branch.
The patch fixes the problem in the same way used in all other X11 headers so
the changes should be pretty much safe.
Comment 21 Roland Mainz 2004-12-07 17:22:34 UTC
Comment on attachment 1493 [details] [review]
[FIXED_X11R68x] xpm.h diff including Changelog, patch for 2004-12-07-trunk

Requesting approval for X11R6.8.x branch... it's a pure "correctness" patch
which should not harm anyone - after the CPP preprocessor phase the resulting
code is identical (we're just using now the "official" X11 way to mark the
begin/end of function prototypes instead of using homegrown C++ code).
Comment 22 Roland Mainz 2004-12-11 15:30:35 UTC
Comment on attachment 1492 [details] [review]
[FIXED_X11R68x] Final patch for X11/extensions/dpms.h (patch for 2004-12-06-trunk)

Approval for X11R6.8.x stable branch granted in the 2004-12-08
release-wranglers phone call.
Please don't commit, I'll do that myself...
Comment 23 Roland Mainz 2004-12-11 15:30:50 UTC
Comment on attachment 1493 [details] [review]
[FIXED_X11R68x] xpm.h diff including Changelog, patch for 2004-12-07-trunk

Approval for X11R6.8.x stable branch granted in the 2004-12-08
release-wranglers phone call.
Please don't commit, I'll do that myself...
Comment 24 Roland Mainz 2004-12-12 19:48:44 UTC
Comment on attachment 1492 [details] [review]
[FIXED_X11R68x] Final patch for X11/extensions/dpms.h (patch for 2004-12-06-trunk)

Patch checked-in into X11R6.8.x stable branch:

/cvs/xorg/xc/ChangeLog,v  <--  ChangeLog
new revision: 1.365.2.34; previous revision: 1.365.2.33
cvs commit: Using deprecated info format strings.  Convert your scripts to use
the new argument format and remove '1's from your info file format strings.
/cvs/xorg/xc/include/extensions/dpms.h,v  <--  dpms.h
new revision: 1.2.4.1; previous revision: 1.2
cvs commit: Using deprecated info format strings.  Convert your scripts to use
the new argument format and remove '1's from your info file format strings.
Mailing the commit message to xorg-commit@lists.freedesktop.org...
Comment 25 Roland Mainz 2004-12-12 19:52:24 UTC
Comment on attachment 1493 [details] [review]
[FIXED_X11R68x] xpm.h diff including Changelog, patch for 2004-12-07-trunk

Patch checked-in into X11R6.8.x stable branch:

/cvs/xorg/xc/ChangeLog,v  <--  ChangeLog
new revision: 1.365.2.35; previous revision: 1.365.2.34
cvs commit: Using deprecated info format strings.  Convert your scripts to use
the new argument format and remove '1's from your info file format strings.
/cvs/xorg/xc/extras/Xpm/lib/xpm.h,v  <--  xpm.h
new revision: 1.2.4.1; previous revision: 1.2
cvs commit: Using deprecated info format strings.  Convert your scripts to use
the new argument format and remove '1's from your info file format strings.
Mailing the commit message to xorg-commit@lists.freedesktop.org...

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.