[PD-dev] how to cast printed pointers? (commit c019784b83 throwing warnings)

Giulio Moro giuliomoro at yahoo.it
Fri Dec 3 09:34:19 CET 2021


Without any specific knowledge to the case at hand, it should normally be `%p` to print a pointer.

Miller Puckette via Pd-dev wrote on 03/12/2021 04:57:
> To Pd dev:
> 
> After merging commit c019784b83 (get rid of a 3 more bogus (unsigned long) casts)
> I'm now getting compiler warnings like this:
> 
> g_editor.c:1884:73: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘struct _glist *’ [-Wformat=]
>   1884 |             snprintf(cbuf, MAXPDSTRING - 2, "pdtk_canvas_setparents .x%lx", c);
>        |                                                                       ~~^   ~
>        |                                                                         |   |
>        |                                                                         |   struct _glist *
>        |                                                                         long unsigned int
> 
> 
> ..
> I presume there's a good reason to change the code (what if "long" is the wrong
> size?) but I'd like to figure out a way to do it that doesn't throw warnings.
> 
> Alternatively, if it doesn't cause bugs to just cast pointers to long for the
> purpose of making tags, let's just revert to the old (unsigned long) cast.
> 
> cheers
> Miller
> 
> 
> 
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev
> 





More information about the Pd-dev mailing list