[cups.development] Port from Debian [Squeeze] to Ubuntu 12.10

Michael Sweet msweet at apple.com
Thu Apr 18 06:19:49 PDT 2013


Peter,

On 2013-04-18, at 8:46 AM, "Peter M. Groen" <pgroen at osdev.nl> wrote:
> 
> This question is asked many times on the different forums, but no answer 
> found...
> 
> I'm switching from Debian (cups 1.4.4) to Ubuntu (cups 1.6.1) and suddenly 
> my compiler is complaining about "forward declarations" in ipp.h and I'm a 
> bit stuck at the moment.
> ...
> This produces the following errors:
> 
> -------------[Compiler output]-------------
> ../lib/printer/printerutil.cpp:xxx:x error: invalid use of incomplete type 
> 'ipp_t {aka struct _ipp_s}'
> -------------[/Compiler output]-------------
> 
> There is no reason (as far as I can see) why this happens. Is the 
> interface changed that much? Do i miss something?


This change is listed in the "what's new in CUPS 1.6" help document; basically we added accessor functions to libcups and made the ipp_t and related structures private in CUPS 1.6.  Aside from making the API a little more future-proof, the change also helps to avoid common coding errors that occurred with developers manipulating the structures directly.

For legacy code you can add "#define _IPP_PRIVATE_STRUCTURES 1" before including <cups/ipp.h> or add "-D_IPP_PRIVATE_STRUCTURES" to your compiler flags, however that should only be used as a last resort - future versions of CUPS will remove this workaround and require you to use the accessor functions.

For this code I would recommend using the ippNewRequest function (added in CUPS 1.2, so it has been around for a very long time) to create your IPP request and set the header fields appropriately:

    ipp_t *request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);

Among other things, ippNewRequest initializes the IPP version and assigns a valid unique request ID for each new request.  Your code can assign an out-of-range number (<= 0 or > 2^31-1) depending on the implementation of rand() and doesn't properly account for newer versions of IPP - two of the common coding errors I was talking about...

_________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair





More information about the cups-devel mailing list