Hallo Hannes, Eric,

On 20.07.2012 19:02, Hannes Weisbach wrote:
>>
>> Now I want to encapsulate the fprintf(stderr, ...) statments by
>> a macro, lets say PRINTF.
> Me too. Although I opted for a function in avrftdi (again, not yet committed).

The reason of my refactoring is to have a shared lib that can be used
e.g. in Python. To do a direct fprintf in a library is not a good
idea. I added a hook where the application can register a callback
function which is in the style of vfprintf. In avrdude main.c then the final fprintf is done ... and if I want to do it Python, the messages can easily go to a Tkinter window after registering the python callback.

>>
>> Which one would be the preffered solution a) or b).
> b).
>
> Also, I would propose that the macro prints the programmer name (if >the message is generated by a programmer) or "avrdude: " if it is >generated by "general" code.

This is a good idea, that the module identifies itself within the generated message.

I also added a severity level, which is currently INFO, WARNING, ERROR
and is also given to the callback function (so the callback implementer could colorize or filter the output).

> What do you think about printing the function name and line number by
>directly by the macro, if the verbosity level is high enough (3 or so)?

Definitely I would like this idea. Is there a way to evaluate the current function name automatically by the preprocessor? (Like the __LINE__ or __FILE__ macros do?)


On 20.07.2012 20:40, Weddington, Eric wrote:
Why do you need to encapsulate these statements behind a macro? (That then has 
to be written and then interpreted by developers when modifications are made...)

You are right, macros does not always help to make the code more readable. But I started with avrdude_message(...) as a replacement
for fprintf(stderr,...) so I felt that it looks somehow sick.

What advantages does it bring, other than shorter typing?

Beside shorter typing, a macro is a method where you can
decouple things, well it might be regarded as german overengineering,
but thats why I was asking.

Greetings Axel.

_______________________________________________
avrdude-dev mailing list
avrdude-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

Reply via email to