Bug 38600

Summary: cairo_svg_surface_create doesn't match API
Product: cairo Reporter: Paul Childs <childsey01>
Component: svg backendAssignee: Emmanuel Pacaud <emmanuel.pacaud>
Status: RESOLVED NOTABUG QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: minor    
Priority: medium CC: freedesktop
Version: 1.10.2   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Paul Childs 2011-06-23 03:08:46 UTC
When using cairo_svg_surface_create in exactly the same fashion as cairo_ps_surface_create (which has an identical API in the documentation) I get a warning from the former but never have for the latter:
assignment makes pointer from integer without a cast

Something seems to be either wrong with the documentation or the code for cairo_svg_surface_create; however, my program still functions fine anyway. It would be nice to not have the warning appear when compiling though.

Here is the code that uses it:

gboolean plot_linear_print_eps(GtkWidget *plot, gchar* fout)
{
	cairo_t *cr;
	cairo_surface_t *surface;

	surface=cairo_ps_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
	cairo_ps_surface_set_eps(surface, TRUE);
	cairo_ps_surface_restrict_to_level(surface, CAIRO_PS_LEVEL_2);
	cr=cairo_create(surface);
	draw(plot, cr);
	cairo_surface_show_page(surface);
	cairo_destroy(cr);
	cairo_surface_finish(surface);
	cairo_surface_destroy(surface);
	return FALSE;
}

gboolean plot_linear_print_svg(GtkWidget *plot, gchar* fout)
{
	cairo_t *cr;
	cairo_surface_t *surface;

	surface=cairo_svg_surface_create(fout, (gdouble) (plot->allocation.width), (gdouble) (plot->allocation.height));
	cr=cairo_create(surface);
	draw(plot, cr);
	cairo_destroy(cr);
	cairo_surface_destroy(surface);
	return FALSE;
}
Comment 1 Benjamin Otte 2011-06-23 04:40:05 UTC
#include <cairo-svg.h> ?
Comment 2 Paul Childs 2011-06-23 07:44:25 UTC
(In reply to comment #1)
> #include <cairo-svg.h> ?

Not directly. I'm wrapping cairo in via GTK and my CAIRO_HAS_SVG_SURFACE variable is enabled. The program is able to still render to svg fine, just I get this warning. It is strange as both cairo-svg.h and cairo-ps.h both have the same declarations for their surface_create functions so I don't know why the compiler would treat them differently.

I get it on both computers I've got one with 1.8.10 and the other with 1.10.2
Comment 3 Behdad Esfahbod 2011-06-23 08:13:54 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > #include <cairo-svg.h> ?
> 
> Not directly.

What do you mean?  So you don't include cairo-svg.h?  That's why you get the warning.
Comment 4 Paul Childs 2011-06-23 11:40:37 UTC
ok seems to do it. How come the include isn't listed in the API? Guess I must just be lazy being used to the GTK API where that's all listed. Also would have thought the compiler would have a different warning. Anyway just excuses for feeling like a fool I guess. Sorry for bothering you guys and thanks for replying so quickly.
Comment 5 Benjamin Otte 2011-06-23 14:43:58 UTC
You want -Wmissing-declarations to get useful warnings for that, though I think -Wall should warn about the function not being defined already.

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.