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

Miller Puckette msp at ucsd.edu
Fri Dec 3 04:57:46 CET 2021


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





More information about the Pd-dev mailing list