On Wed, 30 Dec 2009 22:25:17 +0100
Joerg Sonnenberger <joerg@...> wrote:
> On Wed, Dec 30, 2009 at 10:44:23AM -0200, Gustavo Sverzut Barbieri
> > > Unfortunately there is no safe way of printing it in C89 (ie
> > > windows). The best way is:
> > > printf("... %ld..",(unsigned int)blah);
> %ld and unsigned int? You must be joking... Defining PRIdMAX and
> friends can be easily automated.
I noted that I got it wrong in my follow up post - unsigned long is
the correct cast (Sent almost 12 hours before your email).
> > Given that in many places we use those for logging and logging
> > should move to EINA_LOG and some systems do not handle "%s" with
> > NULL (ie: Solaris, BSDs...), isn't it better to follow
> > Glib/Gstreamer logging and provide our own printf() on these
> > systems, doing clean C99 with GNU niceness (%s+NULL) and avoid ugly
> > thing spread in code?
> IMO it is still better to fix the programs. Besides, printf with NULL
> is checked for on many systems (like the BSDs), the real problem is
> that GCC sometimes decides to replace printf with fputs, which
GCC only does the printf->puts replacement if the first arg if at
compile time it can be sure that:
- fmt does not contain any %'s
- And printf has no extra arguments.
The printf->puts replacement is this only an issue if you are doing:
In which case I'd argue there is something wrong with your code anyway.
The issue which gustavo correctly raised is the problem of
Which will never trip a puts replacement.
Get latest updates about Open Source Projects, Conferences and News.