[parted-devel] avoid printf, when easy to do
Jim Meyering
jim at meyering.net
Wed Feb 14 13:37:29 CET 2007
Otavio Salvador <otavio at debian.org> wrote:
> Jim Meyering <jim at meyering.net> writes:
>
>> Otavio Salvador <otavio at debian.org> wrote:
>>> Jim Meyering <jim at meyering.net> writes:
>>> Your proposed changes looks right but I do think we should provide a
>>> method to make it easier?
>>
>> It's a one time conversion, so making the transition "easier"
>> is less important than making the resulting code readable.
>> Also, with the standard functions, you won't have to publicize
>> the new interface if/when you want to use the same technique
>> in another .c file.
>
> Yes. It'll need to be done once but we'll also continue to code and
> then we'll use it every now and then.
But *everyone* knows about fputs, and no one knows about
a just-invented printp wrapper, be it function or macro.
> By 'publicize' you need the need of #include <foo> on the file header?
If you use a wrapper function, then it has to be declared "extern"
(not static) with a prototype in parted.h.
> Well, while it's true we can also put it together with parted.h since
> it's very specific.
IMHO, it's better to stick to standard mechanisms when possible,
just because they are well known. Of course, if a use requires
a non-trivial %s format, %d, etc., then you'd use printf or fprintf.
My point is that when just printing a literal string, there's no point
in using the *printf functions.
More information about the parted-devel
mailing list