[cairo] Small compiler bug in function '_cairo_ps_form_emit ()'

John Emmas john at creativepost.co.uk
Sun Nov 19 16:01:46 UTC 2017


I just discovered this problem when trying to compile from git master 
(with MSVC 8.0...)

When compiling as 'C' code, some compilers still require that variables 
get declared at the top of a function (i.e. before the main code body 
starts).  But a recent commit (#b1c7a087b5) introduced a change in 
'src/cairo-ps-surface.c', like this:-

       static void
       _cairo_ps_form_emit (void *entry, void *closure)
       {
           cairo_ps_form_t *form = entry;
           cairo_ps_surface_t *surface = closure;
           cairo_emit_surface_params_t params;
           cairo_int_status_t status;

           params.src_surface = form->src_surface;
           params.op = CAIRO_OPERATOR_OVER;
           params.src_op_extents = &form->required_extents;
           params.filter = form->filter;
           params.stencil_mask = FALSE;
           params.is_image = form->is_image;
           params.approx_size = 0;
           cairo_output_stream_t *old_stream;  // <--- NOTE THIS LINE !!!

MSVC complains because 'old_stream' got declared after the start of the 
main code block.  Changing it to this fixes the problem:-

       static void
       _cairo_ps_form_emit (void *entry, void *closure)
       {
           cairo_ps_form_t *form = entry;
           cairo_ps_surface_t *surface = closure;
           cairo_emit_surface_params_t params;
           cairo_int_status_t status;
           cairo_output_stream_t *old_stream; // MOVE THE DECLARATION TO 
HERE !!!

           params.src_surface = form->src_surface;
           params.op = CAIRO_OPERATOR_OVER;
           params.src_op_extents = &form->required_extents;
     // rest of the code....

Regards, John


More information about the cairo mailing list