Hacker News new | ask | show | jobs
by tsbinz 2336 days ago
This works for a literal, but the author was probably thinking of "print a string that comes from somewhere else" where you do the first thing to avoid format characters to be interpreted.
1 comments

Could be. But wouldn't then displayln() require the same string placeholder? Be it "%s", or "{1}" or someting else.
displayln uses the massive _Generic in display_format to supply a large number of formatters automatically. [0]

[0] https://gist.github.com/shakna-israel/4fd31ee469274aa49f8f97...

I see. So when for a char pointer one needs to do

        printf("%p\n", v);
the Generic call must look like this

        displayln((const void *)v);
is it really better?
Or you could have the pointer be a pointer before you feed it to the function.

    void* v;
    v = ...;

    ...

    displayln(v);
The amount of ellipsis shows that your solution is just as heavy weight.