Search code examples
xorgxserver

What is CARD32 data type used in xserver code?


What is CARD32 data-type and where is it defined? I am reading xserver code and am unable to find definitions for CARD data type.


Solution

  • Since the comments on the post cite the wrong code snippet for justification, I wanted to give a proper answer.

    As already noted CARD32 is an unsigned 32 bit integer.

    The type is defined in a C header file in X11/Xmd.h (GitHub Permalink as of 8th Sept. 2021). Here is the revelant excerpt:

    # ifdef LONG64
    typedef unsigned long CARD64;
    typedef unsigned int CARD32;
    # else
    typedef unsigned long long CARD64;
    typedef unsigned long CARD32;
    # endif
    

    Further up, the LONG64 macro is defined only for 64-bit architectures. So, CARD32 is a unsigned int on 64-bit architectures and unsigned long everywhere else.