[argyllcms] Re: X error under AMD64 arch

  • From: Graeme Gill <graeme@xxxxxxxxxxxxx>
  • To: argyllcms@xxxxxxxxxxxxx
  • Date: Tue, 15 Aug 2006 12:44:58 +1000

Mickael Profeta wrote:

I fear this is not true. I have found everywhere that for 64 bits,
pointers and long are 64 bits, and I did not find an option to force
long to be 32 bits in gcc. (-m32 is not an answer as it will compile a
32bit code)

You are right, but the problem you've discovered is an X11 64 bit copatbility problem. How long is an XID ? To be compatibile between X11 clients that may be 32 bit or 64 bit, an XID needs to be 32 bit, so the header declaration of unsigned long is not appropriate if 64 bit compilers are configured to treat it as 64 bit.

If I look in X.h on my Linux system, this is taken care of
for the X server, but not for client code. I'm not sure
why this has been done.

Doing a google search indicates that some code simlply hard codes
the XChangeProperty format at 32 for XA_WM_TRANSIENT_FOR idium,
but the impicit cast will not be right for  big endian architectures
if the XID is 64 bit.

I'm not sure if this issue has been dealt with elsewhere.

You can try this code as a replacement, and see if it works:

            /* Set aditional properties */
            {
                unsigned int xid = (unsigned int)rootwindow;    /* Hope this is 
32 bit */
                XChangeProperty(
                    p->mydisplay, p->mywindow,
                    XA_WM_TRANSIENT_FOR,        /* Property */
                    XA_WINDOW,                  /* Type */
                    32,                         /* format = bits in type of 
unsigned int */
                    PropModeReplace,            /* Change mode */
                    (char *)(&xid),             /* Data is Root Window XID */
                    1                           /* Number of elements of data */
                );
            }
Graeme Gill.

Other related posts: